Link to home
Start Free TrialLog in
Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal

asked on

What is wrong in Regular Expression?

Hi E's,
I create this regular expression:
"^([0-9\u2098\s]*)$"
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,
JC
Avatar of zc2
zc2
Flag of United States of America image

why not just
^[mM0-9]*$

Open in new window

?
What was the intention to use that \u2098 ?

Here is a tester for your expession to play with:
https://www.regextester.com/?fam=109915
Avatar of Pedro Chagas

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What are those "M" characters you are entering? Are they ASCII or from some others character set?