Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

so im not too great with regex and i am trying to search a string for "&option=" plus a number [0-100] so far i have this :

$link = str_replace("^&option[0-9]"," ",$actual_link);

Can any one help me with the correct regex expression.

Thanks in advanced.

share|improve this question
2  
It would be preg_replace as opposed to str_replace –  Ohgodwhy 20 hours ago
    
perfect thank you haha such a simple fix +1 if you could on a comment –  andrew hutchings 20 hours ago
add comment

1 Answer

up vote 2 down vote accepted

Whatever its $ or & (confused by your question), use preg_replace() for your regex replace.

$link = preg_replace("/[&$]option=(?:100|[0-9]|[1-9][0-9])\b/"," ",$actual_link);

And I don't think you need that ^ for the anchoring!

share|improve this answer
    
edited my question too many variables have been written this day. thank you –  andrew hutchings 20 hours ago
    
@andrewhutchings it doesn't matter. It handles both. If you need to remove $, just erase from there! –  Sabuj Hassan 20 hours ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.