How to write a regular expression to match Arabic, English, numeric and spaces?

Using regular expressions in PHP, how can I make the user type Arabic, English, numbers, _, - or a space.

For example, a user may enter the following lines:

  • 10-a bc
  • 10- من
  • 10- ab من
  • _abc من -10
+3
source share
3 answers

To check arabic characters you can use

\p{InArabic}

This page can help you on your journey.

+4
source

, _ - ... [a-zA-Z0-9_-]* ( , , , )... (, , )... , ...

...;)

Greetz

back2dos

0

Try the following:

'/^([a-zA-Z0-9]|[\p{Arabic}]|[_])*$/u'
0
source

Source: https://habr.com/ru/post/1711870/


All Articles