0

I want to be able to match a HTML tag in a given string. The string could be like this

<a href = "http://learnmore.com">Learn </a>.

I have a replace function that replaces the HTML tag with whitespace when I hard code the tag, but I want a regex pattern that can match any characters between the < and > special characters. I have tried a lot, searched a lot on google, but to no avail. I have read posts on the internet that HTML should not be parsed by regex, but here I am only trying a simple matching, so using regex should be OK.

Edited by raghujosh: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by raghujosh
0

You can try replaceAll("<.+?\\>", "")

Wow!!! Thank you so much this worked fantastic. I have been looking for a solution for this all day long. Thanks again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.