0

I have a string that needs to be formatted for HTML with <p></p> tags. That is to say STRING->HTML conversion, and a simple case of only converting to paragraph.

public stringToHtml() {
    INPUT_STRING = "HEADING 1 \r Some Text \r\r HEADING 2 \r Some more Text \r\r";
    String pattern = "^(.+)$";
    String htmlString = pdf.get("TextArea").replaceAll(pattern, "<p>\1</p>");

However the resulting htmlString appears unchanged.

Works on regex101

UPDATE

Tried $1 - but same result (no <p> tags)

String htmlString = pdf.get("TextArea").replaceAll(pattern, "<p>$1</p>");
Mr Lister
  • 44,061
  • 15
  • 107
  • 146
Al Grant
  • 1,715
  • 20
  • 39

0 Answers0