Click here to Skip to main content
15,886,075 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I need to create a program that gets information on a text file and using regular expression is the best way to do this. The information I want to pull has a format.
# = NUMBER @ = ALPHA

##@@@ - this is fixed and I can do this.
##@@@[####][@@] - the character enclosed with [] is optional and i don't know how to create a regular expression on that.

please help thanks.

What I have tried:

[0-9]{2}[A-Za-z]{3} for ##@@@
Posted
Updated 31-Mar-16 7:49am

Read RegEx documentation
perlre - perldoc.perl.org[^]
And use this RegEx debugger to experiment: there is a textboc where you can paste text and you which part match.
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
 
Share this answer
 
Comments
parthgoswami 31-Mar-16 13:50pm    
[^\w+([\s-_]\w+)*$]
Patrice T 31-Mar-16 13:57pm    
no need to copy your solution as comment.
hansoctantan 31-Mar-16 14:48pm    
I use this debugger http://regexstorm.net/tester and it gives me error
Patrice T 31-Mar-16 14:53pm    
gives error on what ?
hansoctantan 31-Mar-16 14:57pm    
nevermind. got an idea with that regex. thanks a lot
C++
[^\w+([\s-_]\w+)*$]


try this
 
Share this answer
 
Comments
Patrice T 31-Mar-16 15:00pm    
This RegEx is weird for the least if not simply buggy.

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