regular expression and forbidden words

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

i'm french, i'm using regular expressions in php in order to rewrite hyperlink tags in a specific way before apache output is beeing sent to client.

Purpose is to replace href attribute of any A html tag by a javascript function calling an ajax loader.

Currently I have wrote that:

  $pattern = '/<a href="(http:\/\/dev.netdoor.fr|(\.))\/index.php\?page=(.*?)">(.*?)<\\/a>/i';
  $replacement = '<a href="javascript:void(0);" OnClick="javascript:yui_fastLoader(\'./systeme/chargeur.php?page=$4\');">$5</a>';
  $html_mark = preg_replace($pattern, $replacement, $html_mark);

it works, but it's too permissive, it replaces too much links (some links with some get parameters must stay unchanged)

I don't really understand my pattern...it's a little strange for me...lol

I wouldn't like to rewrite links that contains any of the following words in get parameters (query string):

  noLoader
  noLeftCol
  skipallbutpage
  skipservice

i would like to rewrite only link that begin with 'http://dev.netdoor.fr' or '.'

examples:

<a href="http://dev.netdoor.fr/index.php?page=./comptes/index.php&noLoader&noLeftCol&idx=6&bdx=423&skipservice";>test</a> 

=>must be not rewritted!

<a class="myclass" href="./index.php?page=./comptes/mediatheque/index.php&filter=mov;flv;mpeg&idx=7">name</a>

=>must be rewritted like this :

<a class="myclass" href="javascript:void(0);" OnClick="javascript:yui_fastLoader(\'./systeme/chargeur.php?page=./comptes/mediatheque/index.php&filter=mov;flv;mpeg&idx=7\');">name</a>


Please help me...:0)

best regards

nicolas

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux