Uranium-235 Posted June 29, 2006 Share Posted June 29, 2006 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. Link to comment https://forums.phpfreaks.com/topic/13167-invalid-characters/ Share on other sites More sharing options...
Eternally777 Posted June 29, 2006 Share Posted June 29, 2006 [!--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) [snapback]389051[/snapback][/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. Link to comment https://forums.phpfreaks.com/topic/13167-invalid-characters/#findComment-50629 Share on other sites More sharing options...
Uranium-235 Posted June 29, 2006 Author Share Posted June 29, 2006 I'm using eregbut I Think I fixed it^[A-Za-z0-9@._-]+$ seems to work so far Link to comment https://forums.phpfreaks.com/topic/13167-invalid-characters/#findComment-50630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.