quimkaos Posted February 1, 2007 Share Posted February 1, 2007 I'm trying to verify if a string has only letters but i also want them with accents (eg: à, á, â and ã) and spaces. im using this: eregi ("^([:alpha: ]+)$", $foo) this will fail with the "special" chars i want. any suggestions? can any1 help please? Link to comment https://forums.phpfreaks.com/topic/36664-regular-expressions-accents/ Share on other sites More sharing options...
effigy Posted February 1, 2007 Share Posted February 1, 2007 <pre> <?php echo $a_s = 'a à á â ã'; echo '<br>'; preg_match_all('/\p{L}/', $a_s, $matches); print_r($matches); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/36664-regular-expressions-accents/#findComment-174827 Share on other sites More sharing options...
quimkaos Posted February 2, 2007 Author Share Posted February 2, 2007 it's not working since i want to use eregi that gives me a boolean type unser. what i'm doing: $fooo = "áà êaaa âotre"; if (!eregi ('/\p{L}/', $foo)){ //ask if $foo uses those chars. a-zA-Z (eregi is case insensitive anyway) and accents like à é ã. simply not numbers $erro ++; // adds +1 to an variable (error) $foo ="<font color='red'>".$foo." - formato do nome é inválido, por favor use um nome válido!</font>"; // makes foo display it's error echo ($nome."</br>"); //... } Link to comment https://forums.phpfreaks.com/topic/36664-regular-expressions-accents/#findComment-175336 Share on other sites More sharing options...
effigy Posted February 2, 2007 Share Posted February 2, 2007 Is there any reason you need to use eregi? The preg_* functions are often faster, and you can supply an "i" modifier to make them case insensitive. If you insist on ereg, I think the only way you can achieve this is by changing your locale. See setlocale. Link to comment https://forums.phpfreaks.com/topic/36664-regular-expressions-accents/#findComment-175413 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.