![]() |
preg_match problem
When I run this expression in preg_match is returns
Quote:
Quote:
Code:
/^(ftp|http|https):\/\/([_a-z\d\-]+(\.[_a-z\d\-]+)+)(([_a-z\d\-\\\.\/]+[_a-z\d\-\\\/])+)*/ |
The problem lies in the final character class definition
[_a-z\d\-\\\/], the escaping back slashes cause it. They're interpreted (by the PHP parser) to be \\/ which the regex parser decides is a single backslash followed by a forward slash, the pattern delimiter. To match a backslash, you'll need four consecutive backslashes (plus 1 escaping the forward slash!): [_a-z\d\-\\\\\/]It might also make life easier if you use a different delimiter for the pattern, which would save you having to escape all of those forward slashes: ~test://~ vs /test:\/\// |
| All times are GMT. The time now is 05:34 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0