[英]Regular expression ignore in PHP
For example there is this line: 例如,有这行:
<a title="best title in the world" href="http://website.com/15661-erko-rhyno/">! Erko_Rhyno !</a>
Now my code returns: 现在我的代码返回:
15661-erko-rhyno/">! Erko_Rhyno !
Im using: 我正在使用:
(?<=\<strong\>\<a title\=\"best title in the world\" href\=\"http:\/\/www\.website\.com\/web\/index\.php\/user\/).*?(?=\<\/a\>\<\/strong\>)
Now I need that it would be without 15661-erko-rhyno/">
like this: 现在,我需要没有
15661-erko-rhyno/">
像这样:
! Erko_Rhyno !
I know why it returns with 15661-erko-rhyno/">
because I specified only ignore this part: 我知道为什么它返回
15661-erko-rhyno/">
因为我指定仅忽略此部分:
<strong><a title="best title in the world" href="http://www.webste.com/web/index.php/user/
But there is the problem now u see this part: 但是现在出现问题了,您可以看到以下部分:
15661-erko-rhyno/">`
Always changes and I don't know how to ignore this part, I will repeat myself and will provide again the code that I'm suing to ignore characters that I don't need:: 总是会变化,而且我不知道如何忽略这一部分,我将重复自己的操作,并再次提供我为忽略不需要的字符而要求的代码:
(?<=\<strong\>\<a title\=\"best title in the world\" href\=\"http:\/\/www\.website\.com\/web\/index\.php\/user\/).*?(?=\<\/a\>\<\/strong\>)
Maybe someone could provide example or answer what I should put in order to ignore those lines whats left? 也许有人可以提供示例或回答我应该写些什么,以便忽略这些行剩下的内容?
Just ignore the > character like 只需忽略>字符,例如
\>([^\>]+)\<\/a\>
to get ! Erko_Rhyno !
得到
! Erko_Rhyno !
! Erko_Rhyno !
in group(1) 在组(1)中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.