php - Problems with preg_match -


I am using preg_match as a way of validating input on a form. Specifically, I am trying to validate the input of currency I is the function:

  if (preg_match ("/ ^ \ $ (((\ d {1,3} ,) + \ D {3}) | \ d +) \. \ D {2} $ / i ", $ inString)) {back true; } And {return false; }  

I can get it to work on all this. I return false, irrespective of what I feed it (including legal stars). I'm sure I'm doing something clearly wrong, but I can not see it. You know how it is ...

Anyone have any suggestions?

Something like this:

  $ inString = '1550.50'; If (preg_match ("/ \ b \ d {1,3} (?:??? \ D {3}) * (?: \. \ D {2})? \ B /", $ inString)) {echo "truth"; } Else {echo "wrong"; }  

Explanation:

  \ b # claim the word limit \ d {1,3} # 1-3 digits (?: # After this group ...,? # An optional comma \ d {3} # exactly three digits) * # ... in any number (?: # After this group ... \. # A literal dot \ d {2} # exactly two digits)? # ... zero or one time \ b # claim limit of the word  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -