Stopp Posted October 16, 2006 Report Share Posted October 16, 2006 gribas uztaisīt tā, lai, ja gadījumā tekstā ir, piemēram, 'haha. haha', tad tas tiek pārveidots par 'haha. Haha'. vārdu sakot pēc puknta un atstarpes burtu jāpārveido par lielo. mēģināju kaut kā burties cauri regexpiem, to burtu pēc punkta apzīmēju ar /. [a-z]/ bet tas laikam nepavisam nav pareizi. kā to varētu realizēt ? visjaukāk būtu ar js, bet var arī ar php. Link to comment Share on other sites More sharing options...
bubu Posted October 16, 2006 Report Share Posted October 16, 2006 . regexpā nozīmē speciālu lietu - jebkuru simbolu. Tev vajag eskeipot to ar backslašu - \. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted October 17, 2006 Report Share Posted October 17, 2006 papeeti PHP f-jas() ucfirst() ucwords() un vispaar str() f-jas.... Link to comment Share on other sites More sharing options...
GedroX Posted October 17, 2006 Report Share Posted October 17, 2006 $s = 'haha. haha'; $dic = Array(); for ($i = 97; $i <= 122; $i++) { $dic['. ' . chr($i)] = '. ' . chr($i - 32); } $s = strtr($s, $dic); Link to comment Share on other sites More sharing options...
v3rb0 Posted October 17, 2006 Report Share Posted October 17, 2006 (edited) bet ja gribās utf8 textam? čērez žē, bet aptuveni strādā. (strstr() taisa jokus ar kirlicu) function char_to_upper($char) { return strtr($char, 'йцукенгшщзхъфывапролджэячсмитьбюqwertyuiopasdfghjklzxcvbnmēūīāšģķļžčņ', 'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮQWERTYUIOPASDFGHJKLZXCVBNMĒŪĪĀŠĢĶĻŽČŅ' ); } $s = 'ļutausis. vēlviens! pavisam pedejais? врь! нш. роь? н'; $exp = '/([\.|\!|\?]\s+|^)([qwertyuiopasdfghjklzxcvbnmēūīāšģķļžčņйцукенгшщзхъфывапролджэячсмитьбю])/u'; while(preg_match($exp,$s,$m)) { $s = preg_replace($exp, '$1'.char_to_upper($m[2]),$s,1); } echo $s; Edited October 17, 2006 by v3rb0 Link to comment Share on other sites More sharing options...
GedroX Posted October 19, 2006 Report Share Posted October 19, 2006 "Nedaudz" īsāk sanāca: $s = preg_replace('/(\.\s+[^\s].)/e', 'mb_convert_case("\1", MB_CASE_TITLE, "UTF-8")', $s); P.S. Nepieciešams mbstring. Link to comment Share on other sites More sharing options...
Recommended Posts