Struggling to find a way to do this so any help appreciated.
Have simple text on single line - and want to match all of the text after the final </p>
tag.
I'm using regex in Open Office - so I need to return a direct match rather than a javascript array.
String looks like this:
<p>Foo bar bar bar foo</p> <p>Foo bar bar foo</p> This Foo bar foo bar <br>
I can match INCLUDING the final </p>
like this:
<\/p>(?!.*<\/p>).*$
I can match it in php regex flavour like this:
(?<=<\/p>(?!.*<\/p>))(.*)(?=$)
And I can get close using this - but it only matches at the first <
- not the whole </p>
string:
(?!.*<\/p>)(.*)(?=$)
Driving me crazy so any help appreciated.
Thanks
Sorry - yes did see the duplicate question but couldn't get it to work - so they said these solutions for their problem:
.*\[\/quote\](.*)$
[\s\S]*\[\/quote\]([\s\S]*)$
Which I transposed to my problem to look like this:
.*<\/p>(.*)$
[\s\S]*<\/p>([\s\S]*)$
Neither of which I could get to work with open office regex - so hence the question.
Sorry I did not catch you wanted after:
</p>
Using this:
.*<\/p>(.*)$
You have an array where the second element is what you look for.
Tested code:
var text = '<p>Foo bar bar bar foo</p> <p>Foo bar bar foo</p> This Foo bar foo bar <br>';
var patt = new RegExp(".*<\/p>(.*)$");
var matched = patt.exec(text);
Tester:
http://www.pythontutor.com/javascript.html#mode=edit
Result:
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.