Reply to Need regular expression or some easier way to do HTML query string text substitution

Your name:

Reply:


Posted by comp.lang.php on 09/26/06 21:03

I am trying to replace within the HTML string $html the following:

[quote]
<a
href="index.php?section=image&refAction=edit&previousRefOrig=edit&chooseAlbum=1&album=here&sort=&willDesc=&willDisplayPanel=&action=move_image">Go
back..</a>
[/quote]

With

[quote]
<a
href="index.php?section=image&refAction=edit&previousRefOrig=edit&chooseAlbum=1&album=here&sort=&willDesc=&willDisplayPanel=&action=edit">Go
back..</a>
[/quote]

Where I'm replacing "action=move_image" 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация