I am trying to figure out how to manipulate string like this:
string abc = "<p> Hello world <em> How are you? </em> abc <em> You there </em> </p>"
into
string def = "<p> Hello world </> <em> How are you? </> <p> abc </> <em> You there </>"
Explanation: For every tag the closing tag will be </> this and I am not allowed to use nested tags as we do in normal HTML. That's why my string def has </> after every opening tag.
<p> hello world </> (tag closed) <em> how are you? </> (em tag closed) <p> abc </> (p tag closed) <em> You there </> (em tag closed)
I tried using exec on regex to find HTML closing tags and replace them with </>. It worked but unfortunately, I couldn't figure out how to work with opening tags.
I also tried splitting a string using space ' ' and looping through the array. But no luck.
Can anyone please guide me through this?
</>) are supposed to represent. Furthermore, you don't even properly quote the initial string, which makes your goal here even more puzzling.abcis not valid HTML(no closingptag) and by just seeing thedef, we are not able to guess the pattern you want.