You are here: Re: Accent characters in regexp « PHP Language « IT news, forums, messages
Re: Accent characters in regexp

Posted by Janwillem Borleffs on 04/06/07 21:17

Laiverd.COM wrote:
> Anyway: below is what I have now, and it allows for a '�' in a
> string. The only solution? Or is there indeed a better way?
>

You can use the "w" character class, which matches both accented and normal
characters, as well as the underscore:

print preg_match('/\w/', '�'); // 1

As it appears that you only want to allow for spaces and hyphens, you could
do something like the following:

$word = '���-';
print !preg_match('/_/', $word) &&
preg_match('/^[\w\s-]+$/', $word); // 1


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация