I have a regex defined follow to match http urls, anyone can help to explain in English?
^/foo/.*(?<!\.css|\.js|\.jpg)$
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Any file or directory in directory
/fooor below that is notcss,jsorjpgfile.So, start of string,
/foo/, maybe some other characters, then string ends – but just before, can’t be.css,.jsor.jpg.EDIT: Apologies for being stubborn. It is indeed an invalid regular expression for most engines, including Perl. The reason is, negative lookbehind must have fixed width; and this lookbehind can be either four characters (in case of
.jpgor.css) or three characters (.js). A fix is to insert an additional “match anything” into the lookbehind so that the width is always four:With that, it works:
OP: Your problem with regexpal.com is the fact that they test for JavaScript regular expressions, which do not implement negative lookbehind at all. Regexp dialects differ in details.