开发者

Regular Expression to capture the last </p> tag and replace it with some text

开发者 https://www.devze.com 2023-01-30 00:27 出处:网络
I want to capture the finaltag in a string. Here\'s what I came up with: /(</p>)$/ Is this going to cause any problems in a typical html script that looks like this:

I want to capture the final

tag in a string. Here's what I came up with:

 /(</p>)$/

Is this going to cause any problems in a typical html script that looks like this:

<p>Copyright 2010 &copy;</p>
<p>Sanscode开发者_JAVA技巧</p>

It seems to work fine, but since i'm new to regex I was wondering if anyone had any caveats or things for me to note. I am using preg_replace().

Thanks


It would not match, if there are whitespace characters behind the last angel bracket.

0

精彩评论

暂无评论...
验证码 换一张
取 消