简体   繁体   中英

regex string followed by a number php string replace

I'm not 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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM