|
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]
|