What is wrong in Regular Expression?

Pedro Chagas
Pedro Chagas used Ask the Experts™
Hi E's,
I create this regular expression:
The objective is just allow the character M or m, and/or numbers from 0 to 9 (ex: m1; m99, 991, mMM10) , but unfortunately don't work.
What I do wrong?

The best regards,
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
why not just

Open in new window

What was the intention to use that \u2098 ?

Here is a tester for your expession to play with:
Pedro ChagasWebmaster


I @zc2, your solution not work. I use like this in js:
function isCE(str){
                          var re = new RegExp("^[mM0-9]*$");
                          if (re.test(str)) {
                              return true;
                          } else {
                              return false;

Open in new window

If I write "11", "1000", etc it work, but if I use "M1", "Mm", don't work!
I am very basic in RE!

Regards, JC
Top Expert 2014
function isCE(str) {
   return /^[m\d]*$/i.test(str);

Open in new window

What are those "M" characters you are entering? Are they ASCII or from some others character set?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial