We can use ^[\/]*$ to match all strings that contain "/".
Similarly, we can use ^[^\/]*$ to match all strings that do not contain "/".
Notice the difference- We just need to add a ^ at the starting of the pattern inside the brackets.
To check for either / or \, the regex ^[^\/|\\\\]*$ can be used. This will negate both / and \.
For more information on regex:-
http://weblogtoolscollection.com/regex/regex.php
http://www.zytrax.com/tech/web/regex.htm
No comments:
Post a Comment