Jump to content


Photo

Invalid Characters


  • Please log in to reply
2 replies to this topic

#1 Uranium-235

Uranium-235
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 29 June 2006 - 12:13 AM

I created this expression, for validating characters for an input field (0-9,a-z,A-Z,'-','_', '@', '.')

^[A-Za-z0-9\.\-_@]+$

It works, except when I test it with an input that contains all correct characters, and a backslash (which is invalid).

when I test this in regex coach with the same string, it works correctly, but when I test it in PHP, it dosen't. It sees "foobar\" as valid, and it's not. When I use other invalid characters, it catches them.
Random Quote:[br][br][url=http://www.paintbug.com/scripts/quote_source.phps]

#2 Eternally777

Eternally777
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 June 2006 - 01:08 AM

[!--quoteo(post=389051:date=Jun 28 2006, 08:13 PM:name=Uranium-235)--][div class=\'quotetop\']QUOTE(Uranium-235 @ Jun 28 2006, 08:13 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I created this expression, for validating characters for an input field (0-9,a-z,A-Z,'-','_', '@', '.')

^[A-Za-z0-9\.\-_@]+$

It works, except when I test it with an input that contains all correct characters, and a backslash (which is invalid).

when I test this in regex coach with the same string, it works correctly, but when I test it in PHP, it dosen't. It sees "foobar\" as valid, and it's not. When I use other invalid characters, it catches them.
[/quote]

What function are you using? Regex Coach appears to be designed for Perl.

#3 Uranium-235

Uranium-235
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 29 June 2006 - 01:14 AM

I'm using ereg

but I Think I fixed it

^[A-Za-z0-9@._-]+$ seems to work so far
Random Quote:[br][br][url=http://www.paintbug.com/scripts/quote_source.phps]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users