Regular Expression for even number

· November 3, 2008

Let me first be very clear - I’m not a RegExp-guy. I find them quite hard to understand at times and often take my refuge to the .NET-code.

Also I was very surprised to not find any hits for the search of “RegExp even numbers” - I thought that I would find numerous examples.

But after reading a bit at this place I learned enough to create my first own, naïve regular expression - a regular expression to allow only even numbers:


Again - my apologies for being a newbie on this… but hey it works.

I also found this resource very useful for trying my expression out.

Regular Expressions are very powerful but “with great powers comes great responsibilities”… that is they are often hard to understand.

Thanks Fredrik S for the links.

Twitter, Facebook