找到一个正则表达式来检查字母,汉字和斜杠(/) [英] find a regular expression to check letter,chinese character and slash(/)

查看:156
本文介绍了找到一个正则表达式来检查字母,汉字和斜杠(/)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入姓名时,我想查看用户的输入值,如果他的输入是英文名字,则该名称只包含字母,并且必须用斜杠(/)分隔,例如:
GeorgeBush,George Bush,GeorgeBush /,dsfsdf / 是错误的;乔治/布什,fdfd / fdfd / sds 是对的。
i找到一个这样的正则表达式: / ^ [a-zA-Z\\\一-\\\龥\ /] {1,20} / 。但是它不能检查 fsfd / / fdsf 。请给我一些建议。谢谢!

i want to check users' input value when he input his name, if his input is a English name, the name only contains letters and must be divided with slash(/), example: GeorgeBush, George Bush,GeorgeBush/, dsfsdf/ are wrong; George/Bush, fdfd/fdfd/sds are right. i have find a regular expression like this:/^[a-zA-Z\u4E00-\u9FA5\/]{1,20}/. But it can't check fsfd/ or /fdsf. please give me some suggestions. thanks!

推荐答案

不清楚你想要什么,也许这样:

Not clear exactly what you want, maybe this:

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

这篇关于找到一个正则表达式来检查字母,汉字和斜杠(/)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆