Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can someone help me to find RegEx pattern for this format of string


/AC011/20_ABC/AEEE/ACD_AEEE_Opw21_1
123
 
1.1.1.11.0-11


Thanks in advance,
Posted
Comments
Andreas Gieriet 15-Jan-13 4:21am    
What exactly to you want to match?
Your question is like: "can you please highlight my favorite words in this sentence". ;-)
Cheers
Andi
helloworld2020 15-Jan-13 4:27am    
You're right my mistake. I want to match that whole string with new lines, spaces.
Same as it in qoutes.
"/AC011/20_ABC/AEEE/ACD_AEEE_Opw21_1
123

1.1.1.11.0-11"

Thanks in advance :)
Andreas Gieriet 15-Jan-13 4:36am    
1) What language? C#?
2) What RegEx dialect? .NET?
3) Why RegEx when you want the full string to "match"? Why not use s1.Equals(s2) or s1 == s2?
Andi

1 solution

Regex is probably the wrong tool, unless you are trying to match that string as a pattern:
"A slash, followed by two uppercase Alpha, and three digits, then a other slash, followed by ..."
If you want to find an exact string, then use string comparison instead - it's a lot easier and a lot simpler to read!
If you want to match a pattern, then you need to give us a bit more info on what is and isn't allowed where - and what you need to break it into as far as match groups are concerned. Get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.

And try starting with:
/(?<id>[A-Z]{2}\d{3})/(?<productcode>\d{2}_[A-Z]{3})</productcode></id>
Which may cover the first two fields.
 
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