Java Regex to check "=number", ex "=5455"? -


i want check string matches format "=number", ex "=5455".

as long fist char "=" & subsequence number in [0-9] (dot not allowed), popup "correct" message.

    if(str.matches("^[=][0-9]+")){         window.alert("correct");         } 

so, ^[=][0-9]+ correct one?

if not correct, can u provide correct solution?

if correct, can u find better solution?

i'm no big regex expert , more knowledgeable people me might correct answer, but:

  • i don't think there's point in using [=] rather = - [...] block used declare multiple choices, why declare multiple choice of 1 character?
  • i don't think need use ^ (if input string contains character before =, won't match anyway). i'm unsure whether presence makes regex faster, slower or has no effect.

in conclusion, i'd use =[0-9]+


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -