Alex Rivera | Logout

Regex to check if a number is even

Asked 2010-09-08T08:53:34.393
9

Can we have a regex to detect if a number is even ?

I was wondering if we can have a regex to do this instead of usual % or bit operations.

Thanks for replies :)

Edit
Report

1 Answer

3

If it is a string, just check if endsWith(0) || endsWith(2) || .. returns true. If it is number, it is very simple.

answered 2010-09-08T09:00:45.937

Your Answer