I use below code to have something like this: " محمد125 hasan ". with a limit of being between 3 and 25 characters. but it doesn't work.
(^[ \d\p{Arabic}a-zA-Z0-9 ]{3,25}$)
Plain and simple:
^[\d\p{L}\h]{3,25}$
# match the start (^), digits or any letter
# and horizontal space three to 25 times
# end of the string/line ($)
In PHP
this would be:
$string = 'محمد125 hasan ';
$regex = '~^[\d\p{L}\h]{3,25}$~';
if (preg_match($regex, $string, $match) {
// do sth. useful here
}
See a demo on regex101.com .
Just use \\w with u
modifier which means unicode
/^[ \d\p\wa-zA-Z0-9 ]{3,25}$/u
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.