Page 1 of 1

Help with a regex - Not containing a string

Posted: Tue Mar 01, 2011 6:14 pm
by M4ngo
Hi I suck with regex - please help.

Need to parse a HTML document for script tags. Within these script tags, I need to match Javascript legal forms of the following:
document.form.action = "/some/URL";
but where "some/URL" does NOT START with "/FOO-"

So, I should match:
document.form.action="someother/URL";
AND
document.form.action = "someother/URL/1/2/3jhkj" ;
AND
document.form.action=
"someother/URL";

I also need a reference to the URL "/some/URL" because I need to encrypt it...

I have tried:
'#(document\.form\.action)[\s]*=[\s]*["\']([^(/FOO-)][.]*)["\']#'

Re: Help with a regex - Not containing a string

Posted: Wed Mar 02, 2011 10:29 am
by AbraCadaver
This should work:
[text]'#document\.form\.action[\s]*=[\s]*["\'](?!/FOO-)([^"\']+)["\']#'[/text]