faqts : Computers : Programming : Languages : PHP : Common Problems : Regular Expressions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

how can i change 2nd part of url that starts with qid= and replace everything that follows with "hi"

Dec 1st, 2003 13:04
Jakub Vrana, Arman Galstyan,


<?php
ereg_replace("(\\?(.*&)?)qid=[^&]*", "\\1");
?>
\\? - question mark
(.*&)? - optional parts before qid
[^&]* - everything before first & (or to the end, if & is missing)
Remember, parameters in URL are separated by &.