1

I set two flags for a text string, I hope to replace all the content between the flag <!--BeginOfReplace--> and the flag <!--EndOfReplace-->.

I think the regular expressions can do it, how can I write a code in Java? Thanks!

Text String

This is a cup

<!--BeginOfReplace-->     

   Hello, world !

<!--EndOfReplace--> 

I will go back. 
HelloCW
  • 476
  • 10
  • 77
  • 178

1 Answers1

0

There is great library call jsoup.Jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods. Great tutorial = > https://inducesmile.com/android/android-html-parser-using-jsoup-tutorial/

String html = "<p>An <a href='http://example.com/'><b>example</b>  </a> link.</p>";
Document doc = Jsoup.parse(html);
  Element link = doc.select("a").first();

thats an example, can you work from there.

Remario
  • 3,455
  • 2
  • 14
  • 22