Click here to Skip to main content
15,886,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to check a string against a particular occurrence that is, whenever a "/" occurs it must followed by a character or number like "/z" or "/2" or "/s".

Anyone, Please help on this as I'm new to RegEx.

I Appreciate any help.
Thanks in Advance.
Posted

Try:
/[sz2]
The '[' and ']' characters say "any character in this list".
Get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
 
Share this answer
 
Comments
Sunny_Kumar_ 13-Jun-12 6:23am    
Thanks a lot for this help. I'm gonna try this.
OriginalGriff 13-Jun-12 6:34am    
You're welcome!
VJ Reddy 14-Jun-12 0:36am    
Good suggestion. 5!
Manas Bhardwaj 15-Jun-12 3:54am    
Correct +5
The Expresso program suggested by OriginalGriff is really a very good tool. It has a design mode it which the regular expression can be built interactively and it can be tested.

Alternatively, if you want to check immediately online, the http://regexhero.net/tester/[^] is a good online Regular Expression tester for testing the regular expression and it also offers help on building the regular expression.

For the case stated in the question, since any character (a to z or A to Z) or any number must follow / then I think the following regular expression

/[a-zA-Z0-9]
or
/[\w-[_]]
can be used. \w matches alpha numeric character a-z A-Z 0-9 and UnderScore. Since, under score is not required in the present case it is subtracted.

It can be tested at the above website.
 
Share this answer
 
v2
Comments
Sunny_Kumar_ 14-Jun-12 1:10am    
Thanks a lot for the nice link. The site is really very nice and doing well as Expresso online I would say. Love this tool..thanks again :)
VJ Reddy 14-Jun-12 1:23am    
You're welcome and thank you for reviewing and accepting the solution :)
Manas Bhardwaj 14-Jun-12 4:25am    
Correct +5
VJ Reddy 14-Jun-12 4:36am    
Thank you, Manas :)
Espen Harlinn 14-Jun-12 17:09pm    
Nice answer, 5'ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900