Welcome Guest, Not a member yet? Register   Sign In
regular expression is not working
#1

[eluser]samitrimal[/eluser]
Hi i have a problem in using dollor sign in my regular expression . When i dont use dollar sign it works fine.Here is a code
Code:
$pattern="/^[^0-9][0-5a-zA-Z]{1,}([a-zA-Z0-9_|-])*$/";
if (preg_match($pattern, "a12-|", $matches)) {
  echo "Match was found <br />";
  echo $matches[0];
}
else{
  echo "Pattern does not match";
}
The error occours when i use dollor sign.
Code:
$pattern="/^[^0-9][0-5a-zA-Z]{1,}([a-zA-Z0-9_|-$])*$/";
if (preg_match($pattern, "a12-|$", $matches)) {
  echo "Match was found <br />";
  echo $matches[0];
}
else{
  echo "Pattern does not match";
}
I encountered the following error
Code:
Warning: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 36 in E:\wamp\www\graph\testpractice\php\regex\pregmath.php on line 3
need help to solve this problem


Messages In This Thread
regular expression is not working - by El Forum - 05-26-2011, 12:17 AM
regular expression is not working - by El Forum - 05-26-2011, 01:19 AM
regular expression is not working - by El Forum - 05-26-2011, 02:29 AM
regular expression is not working - by El Forum - 05-26-2011, 05:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB