I have some text whereby I need to replace only single line breaks (\n
) with a <br />
, but not when followed/preceded by another line break or carriage return (\r\n
or \r \n
or \n \n
or \n\n
)
According to another answer, I can use regex (\S.*?)\R(.*?\S)
with replace as $1
$2.
This works great, however I need to avoid using this when inside certain tags such as <ul>, <h2> and <blockquote>
How can I modify the regex to avoid specific tags?