开发者

Add additional character filter to regular expression

开发者 https://www.devze.com 2023-03-31 06:02 出处:网络
I have regular expression which is checking for at least one character or number: ^(?=.*[a-zA-Z])(?=.*[0-9]).*$

I have regular expression which is checking for at least one character or number:

^(?=.*[a-zA-Z])(?=.*[0-9]).*$

I want to add one more condition there to 开发者_运维技巧exclude forward slash:

I know that to exclude forward slash would be something like that [^/] but i don't know how exactly put it to my regex.

May be someone may help me with that?


^(?=.*[a-zA-Z])(?=.*[0-9])[^/]*$

That's all there is to it.

The dot . means "any character". The * repeats the previous token 0 or more times. So

[^/]*

means "zero or more non-slash characters", whereas

[^/].*

means "one non-slash character, followed by zero or more characters of any kind".

0

精彩评论

暂无评论...
验证码 换一张
取 消