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

I wanted to understand how can I use regEx in C++ using visual studio 2010.

I have below requirements.

RegEx :   [0−9]{3}[0−9a−zA−Z]{3} [0−9a−zA−Z]{2} [0−9]  //Regular expression, 

Here there is range of valid chars in [] and value inside {} denotes the number of charactes that should comply with rule.


[0-9]{3} means that first three charcters of string should be a number in range 0 to 9.

[0−9a−zA−Z]{3} means that next 3 chars of string can be anything in range 0-9 or a-z ot A-Z.



Below are valid and invalid strings considering above rule.
120 aBZ K8 7 - Valid


AX0 aBZ K8 7 - Not Valid


120 @1k0 _1 _  - Not valid


120 1BZ 18 7 - Valid



Any help is appreciated.

What I have tried:

checked few blogs but i could not find anything for my requirements implemented in c++ for visual studio 2010.
Posted
Updated 16-Aug-18 3:22am

 
Share this answer
 
Comments
joyjhonson 17-Aug-18 4:11am    
Thank you
OriginalGriff 17-Aug-18 4:20am    
You're welcome!
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
 
Share this answer
 
Comments
joyjhonson 17-Aug-18 4:11am    
Thanks you

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