[英]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]. 我对正则表达式不太满意,我正在尝试在字符串中搜索“&option =”加上数字[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. 无论其
$
或&
(与您的问题混淆),请使用preg_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! 而且我认为您不需要
^
来进行锚定!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.