ORF Forum  >  ORF Technical Support  >  Really easy regex question (or two)

Really easy regex question (or two)

 
Besides the obvious question ("is there a utility that can take your English words and turn them into a logical regex expression")...

I ask you this: can you help me with building a regex (and understanding how it works - I learn by example) which says:

"match any amount of letters followed by any two numbers followed by any one letter followed by @ followed by anything else"



Bryon (5 months ago)
As for the tool, I personally prefer the expression builder feature of Expresso (http://www.ultrapico.com/Expresso.htm). Others prefer Regex Coach (http://weitz.de/regex-coach/), try both and see which of them you find more suitable.

As for understanding how regexes work, I recommend this tutorial:

http://www.codeproject.com/KB/dotnet/regextutorial.aspx

And finally, as for the regex, the following should work:

[a-zA-Z]*\d{2}[a-zA-Z]@.*

It means any letters, either upper- or lowercase ([a-zA-Z]), any number of repetitions (*) followed by any number (\d) exactly two times ({2}) followed by any letter ([a-zA-Z]) followed by @ followed by any character (.) any number of repetitions (*).
Krisztian Fekete (Vamsoft) (5 months ago)
in response to
Or, if by "letters" you mean basically any characters BUT numbers, use

\D*\d{2}\D@.*

\D means "not a digit", this will match characters like questionmark (?) or the number sign (#) as well.
Krisztian Fekete (Vamsoft) (5 months ago)
Wow expresso is exactly what i was looking for - i'll learn this utility

Thanks for the expression and explanation there - the aspects i have trouble with are the placement of the modifiers. For example "*[a-zA-Z]" is what logically makes sense to me in that the letters would modify the wildcard... but i understand how it's actually the * that modifies the group of letters

I'll learn this stuff eventually though :) regex is incredibly powerful if you know how to use it.

Thanks for putting up with all my questions over the years

Bryon (5 months ago)
You are welcome :) That is what we are here for, so if any further questions arise, ask anytime.
Krisztian Fekete (Vamsoft) (5 months ago)

1. Your name:

2. Your email address (will not be published):

3. Your comment:

4. Please enter the words below: (must be completed only once)