I am trying to replace within the HTML string $html the following:
With
Where I'm replacing "action=move_im age" with "action=<?=
$_REQUEST['refAction'] ?>"
I'm using regular expressions to do just that, or at least I'm trying:
[PHP]
$html = preg_replace('/([&\?])action=[^&">]*([&"])([^>]*>Go
back.*$)/', '$1action=' . $_REQUEST['refAction'] . '&blah=foo' . $pagQS
.. '$2$3', $html);
[/PHP]
I'm using "&blah=foo" as my test to see if preg_replace() has taken
place, so far, it hasn't.
Several class methods spawn the query string before "Go back.." several
different ways; however, there will always be a "action=[something]"
within the query string for you to change, just cannot predict where;
furthermore, there MAY also include "refAction=[something]" within the
same query string.
How do I do this either with regular expressions or some other way?
Thanx
Phil
<a
href="index.php ?section=image& refAction=edit& previousRefOrig =edit&chooseAlb um=1&album=here &sort=&willDesc =&willDisplayPa nel=&action=mov e_image">Go
back..</a>
href="index.php ?section=image& refAction=edit& previousRefOrig =edit&chooseAlb um=1&album=here &sort=&willDesc =&willDisplayPa nel=&action=mov e_image">Go
back..</a>
<a
href="index.php ?section=image& refAction=edit& previousRefOrig =edit&chooseAlb um=1&album=here &sort=&willDesc =&willDisplayPa nel=&action=edi t">Go
back..</a>
href="index.php ?section=image& refAction=edit& previousRefOrig =edit&chooseAlb um=1&album=here &sort=&willDesc =&willDisplayPa nel=&action=edi t">Go
back..</a>
$_REQUEST['refAction'] ?>"
I'm using regular expressions to do just that, or at least I'm trying:
[PHP]
$html = preg_replace('/([&\?])action=[^&">]*([&"])([^>]*>Go
back.*$)/', '$1action=' . $_REQUEST['refAction'] . '&blah=foo' . $pagQS
.. '$2$3', $html);
[/PHP]
I'm using "&blah=foo" as my test to see if preg_replace() has taken
place, so far, it hasn't.
Several class methods spawn the query string before "Go back.." several
different ways; however, there will always be a "action=[something]"
within the query string for you to change, just cannot predict where;
furthermore, there MAY also include "refAction=[something]" within the
same query string.
How do I do this either with regular expressions or some other way?
Thanx
Phil
Comment