I have an html string that I want to separate into 3 substrings. Each time there is an < h2 > tag, I want that to be the start of the new section. This way it can go into the body of an email.
I thought I could achieve this by using < h2 > as a a separator in a split function, but its not working as I hoped.
What’s the best approach here? Regex?
Note, I added the space around the tag so it wouldn’t format in the forum.
It is hard to say what the issue is without knowing exactly what you mean by “not working as I hoped”. I just did a quick test and it works fine on my end: