[Solved] How to create regex to test for a number in an expression?


You could always use regex to match e.g allowed words [a-zA-Z] and digits \d or [0-9] to match e-mail adresses with at least one digit and one character as such:

([a-zA-Z]+\d.+)

which only matches [email protected] because it fulfils the criteria.

Or to go further, use word boundaries to demand @ and ., such as:

([a-zA-Z]+\d+\b@.+\b.+)

If you wish to match letters and digits after the @, you can use:

([a-zA-Z]+\d+\b@.+[a-zA-Z0-9]\b.+)

Test it out yourself on http://rubular.com/.

2

solved How to create regex to test for a number in an expression?