Find a regex to validate a letter, Chinese character, and slash (/)

I want to check the input value of a user when he enters his name, if his input is an English name, the name contains only letters and should be separated by a slash (/), for example: GeorgeBush, George Bush,GeorgeBush/, dsfsdf/ are incorrect; George/Bush, fdfd/fdfd/sds are correct. I have a regular expression: /^[a-zA-Z\u4E00-\u9FA5\/]{1,20}/ . But he cannot check fsfd/ or /fdsf . please give me some suggestions. thanks!

+1
source share
1 answer

It's unclear what you want, maybe this:

 ^(?=.{1,20}$)[a-zA-Z\u4E00-\u9FA5]+(?:\/[a-zA-Z\u4E00-\u9FA5]+)?$ 
+2
source

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


All Articles