I would like to have a regular expression that matches:
- Arabic letters.
- List item
- English alphanumeric.
- 3 Spaces maximum.
- 4 Underscores maximum.
Any order.
I tried varies solution but couldn’t solve it.
Here is what i have now:
preg_match('@^([^\W_]*\s){0,3}[^\W_]*$@', $username)
The above expression allows:
- 3 spaces maximum
- English alpanumerics
- No underscore allowed
I don’t know about arabic characters, but the following regexp should match the others
This will match
(Alphanumeric)(0-3 spaces)(0-4 underscores)
If there are more than 4 underscores, the last ones will be omitted
If there are more than 3 spaces then the part after the 3 spaces will be ignored.
EDIT:
For arabic letters: First declare a string containing all arabic letters
so you’ll have
Then your regexp string will be
And match it as follows: