Jump to content

Archived

This topic is now archived and is closed to further replies.

cgchris99

how to preg_match_all with single quotes

Recommended Posts

Need to parse out this piece of code...
-----------------------------------------------------------------
theForm.action = 'Browse.aspx?MyAction=632966656416040865';
        theForm.submit();
-----------------------------------------------------------------
What I need is the number after MyAction. But I can't get my code to work.  It seems to have trouble with either the single quote or the semicolon. Here is what I have coded

preg_match_all("#MyToken=(.*?)/';#s",$page,$myaction);

But this doesn't work.  What do I have wrong?

Thanks for any advice or help.


Share this post


Link to post
Share on other sites
MyToken should be MyAction and you don't need the forward slash.

Share this post


Link to post
Share on other sites
That's an oops on my part.  It actually is
preg_match_all("#MyAction=(.*?)/';#s",$page,$myaction);

But it still doesn't work.

Share this post


Link to post
Share on other sites
[code]preg_match_all ( "!(?<=myaction=)\d+!si", $page, $myaction );[/code]

results will be in

$myaction[0];

I do it this way, so you only return the data you want, no need for more arrays!


me!

Share this post


Link to post
Share on other sites

×

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.