Reputation: 69
Suppose I have
<img class="size-full wp-image-10225" alt="animals" src="abc.jpg"> blah blah blah
<a href="http://en.wikipedia.org/wiki/Elephant">elephant is an animal</a> blah
I want a regex to give me the output :
blah blah blah <a href="http://en.wikipedia.org/wiki/Elephant">elephant is an animal</a> blah
without the
. I can do str.replace(" ","")
separately, but how do I get the string starting from blah blah...
until blah
(which includes link tag).
Upvotes: 0
Views: 614
Reputation: 71538
Maybe something like this?
^<[^>]*>\s*|
Java escaped:
^<[^>]*>\\s*|
^<[^>]*>\\s*
will match the first img
tag and any following spaces. Then replace the
. The replacement string is ""
.
You might want to use a proper HTML parser though, since it'll be less likely to break.
Upvotes: 2