I want a regular expression, which should start with alphabet or numbers and followed by alphanumeric character and in between, it may or may not contain forward or backward slash ( \\,/
).
Highly appreciate your help.
Thanks :)
/^[a-z0-9][\w\\\/]+$/i
^
). [a-z0-9]
- a letter or number - 1 occurrence [\\w\\\\\\/]+
- multiple occurrences of alphanumeric characters (including _
) or \\
or /
. $
). i
gnore-case flag will accept both uppercase and lowercase.
[xyz]
specifies a character class meaning that either x
or y
or z
can be matched.
If you don't consider 123_asd
to be alpha-numeric, use:
/^[a-z0-9][a-z0-9\\\/]+$/i
Hope it helps!
^[a-zA-Z0-9]+[a-zA-Z0-9\/\\]*
This will accept / or \\ only in between.
Edit: Oops:p Missed the numbers, updated. Thanks for pointing out.
Try this regex:
(?i)^[a-z\d][a-z\d\\/]*$
?i
treats upper-case letters as lower-case letters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.