Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove the <br/> using regex in java?

Tags:

java

string

regex

how to get value without <br/> tag using regex n java?

my String is:

<Div>
  West Newton, MA 02465
    <br/>USA
</Div>

output should be like:

West Newton, MA 02465
USA

my pattern is like:

Pattern p8 = Pattern
                .compile("<div class=\"leftLabel\">Nickname</div>\\s+<div class=\"rightContent\">([^<]*)</div>");
Matcher m8 = p8.matcher(responseBody);

i didnt get anything as result. what i have to put there(instead of ([^<]*)).

How?

like image 371
Praveen Avatar asked Dec 02 '25 10:12

Praveen


1 Answers

Are you sure you need regex for it?

why not just remove all tags, e. g. replace '<br/>' with "" or "\n", as you like?

like image 170
Ilya Smagin Avatar answered Dec 05 '25 00:12

Ilya Smagin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!