Re: Little regex tweak help please

From: Date: Sun, 10 Oct 2004 10:50:02 +0000
Subject: Re: Little regex tweak help please
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-199102@lists.php.net to get a copy of this message
Nick Wilson wrote:
hello all, I am using preg_match() to find the action attribute on a form. This regex works very well: preg_match('/action\s*=\s*"([^"]+)"/i', $result, $actionval); However, if my user has put another form above the one im looking for, (like a search box) it fails to grab the correct action attr. The html *always* looks like this: <form method="post" action="http://example.com/someForm.cgi" name="user_notification" [some other stuff here]> This is my attempt to find the correct one so far: '/action\s*=\s*"([^"]+)".*name\s*=\s*"([^"]+)"/is' im having trouble putting the 'user_notification' bit in... This does not work: '/action\s*=\s*"([^"]+)".*name\s*=user_notification\s*"([^"]+)"/is' Can anyone help? - much thanks ;-)
You missed the quotes around user_notification, and also possible white chars

« previous php.general (#199102) next »