I have a html string like this
<div>
<p>
All set to go in.
Finally in.
</p>
<pre>
Yup this text is present
inside of the pre tag.
</pre>
</div>
I want to replace line breaks presents inside pre tag with <br> tags.
Final result should be.
<div>
<p>
All set to go in.
Finally in.
</p>
<pre>Yup this text is present<br> inside of the pre tag.</pre>
</div>
What I have tried so far?
I tried to this with regex and created pattern which looks like this :-
/is(?=.*<\/pre>)/g
which is only capable of finding 'is' which are before </pre>
tag. I also want to include one more condition in this, i.e it should if after <pre>
tag. Try this regex at https://regex101.com/r/qW7tZ1/5
How do I replace all line breaks in a string with <br /> tags? doesn't fit my condition as I don't want to replace all occurrence of line break.