Hi
how can I set this preg_match in order to get those letters: à è ì ò ù ?
preg_match('/[.a-zA-Z0-9]{1,15}$/
thanks
Hi
how can I set this preg_match in order to get those letters: à è ì ò ù ?
preg_match('/[.a-zA-Z0-9]{1,15}$/
thanks
You could include the characters in the character class, and append a [font=monospace]u[/font] modifier to the pattern; if you do this you should ensure that the script file is saved as UTF-8 and that you're passing UTF-8 encoded text to the function when you use it (of course if you're wanting to deal with characters that lie outside plain ASCII you should be doing this already for sanity's sake).
There's also the [font=monospace]\w[/font] character class shortcut, which matches any character that looks "word-like", depending on the current locale.
I believe you could also use these escape sequences:
\x85
\x8A
\x8D
\x95
\x97
Weedpacket;11038555 wrote:You could include the characters in the character class, and append a [font=monospace]u[/font] modifier to the pattern; if you do this you should ensure that the script file is saved as UTF-8 and that you're passing UTF-8 encoded text to the function when you use it (of course if you're wanting to deal with characters that lie outside plain ASCII you should be doing this already for sanity's sake).
There's also the [font=monospace]\w[/font] character class shortcut, which matches any character that looks "word-like", depending on the current locale.
i've tried those two syntax but they doesn't work:
preg_match('/[.\w0-9]{1,15}$/
preg_match('/[.\x85\x8A\x8D\x95\x970-9]{1,15}$/
Where is the mistake?
At least in the second one, you still need your "A-Za-z" along with the hex code escape sequences, e.g.:
'/^[.A-Za-z0-9\x85\x8A\x8D\x95\x97]{1,15}$/'
joane1;11038579 wrote:preg_match('/[.\w0-9]{1,15}$/
preg_match('/[.\x85\x8A\x8D\x95\x970-9]{1,15}$/
Where is the mistake?
You are missing Weedpacket's suggested pattern modifier
Weedpacket;11038555 wrote:You could include the characters in the character class, and append a [font=monospace]u[/font] modifier to the pattern; if you do this you should ensure that the script file is saved as UTF-8 and that you're passing UTF-8 encoded text to the function when you use it (of course if you're wanting to deal with characters that lie outside plain ASCII you should be doing this already for sanity's sake).