Help with a regex - Not containing a string

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
M4ngo
Forum Newbie
Posts: 6
Joined: Fri Jul 18, 2008 8:27 pm

Help with a regex - Not containing a string

Post 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-)][.]*)["\']#'
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Help with a regex - Not containing a string

Post by AbraCadaver »

This should work:
[text]'#document\.form\.action[\s]*=[\s]*["\'](?!/FOO-)([^"\']+)["\']#'[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply