Jump to content

Recommended Posts

[!--quoteo(post=355434:date=Mar 15 2006, 01:43 PM:name=curtm)--][div class=\'quotetop\']QUOTE(curtm @ Mar 15 2006, 01:43 PM) [snapback]355434[/snapback][/div][div class=\'quotemain\'][!--quotec--]
How would I accomplish the following...

In a string containing either

action="target.php"

or

action=target.php
how would I strip out everything except target.php ? I am going to be using this on multiple forms, and i have no idea whether the forms will have the quotes or not.

thanks!
[/quote]

you can grab all the actions out of a string using a combination of the following:
[code]
$string = "action=\"target.php\" | action='target.php' | action=target.php";

// first match for those with single or double quotes
preg_match_all("/action=(['\"])(.+?)(?:\\1)/i", $string, $matches);

// next, match for those with no quotes at all
preg_match_all("/action=([a-z.\/_]+)/i", $string, $matches2);
echo "<pre>\n";
print_r($matches);
print_r($matches2);
echo "</pre>\n";

[/code]

hope this helps
Link to comment
https://forums.phpfreaks.com/topic/5054-how-do-i-do-this/#findComment-17902
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.