Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Need to match regex for below patterns
I/p: 101-123
O/p: 101-123

What I have tried:

private Regex Example = new Regex(@"^\d{3}-\d{3}(-[A-Z0-9]+)?(\([A-Z0-9]+\))?(\s[a-zA-Z0-9]+)*$");
Posted
Updated 22-Feb-23 3:58am
v2
Comments
PIEBALDconsult 21-Feb-23 16:03pm    
I think a copy of Expresso is in your future.
RedDk 22-Feb-23 13:20pm    
... eyeah, Expresso: free (NOT!) ...

A good site for experimenting with/Learning RegEx is regex101: build, test, and debug regex[^]
 
Share this answer
 
Try:
\d+-.+?[\s$]
If you are going to use regular expressions, you need a helper tool. Get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
 
Share this answer
 

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