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>");
` and then wrap the entire string with `
` and `
`. If you want to keep the new lines, then replace them with `\r`.
– Racil Hilan Feb 02 '18 at 23:08