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
  • 45,515
  • 15
  • 108
  • 150
Al Grant
  • 2,102
  • 1
  • 26
  • 49

0 Answers0