I have strings that look like this:
"<span>X</span>間違<span>う</span><span>ABCDE</span>"
How can I add spans to the elements that do not have spans already so the string looks like this:
"<span>X</span><span>間</span><span>違</span><span>う</span><span>ABCDE</span>"
Is this something that I can do with Regex?
Example 2 source
"<span>X</span>A<span>う</span>ABC<span>Y</span>"
Example 2 result
"<span>X</span><span>A</span><span>う</span><span>A</span><span>B</span><span>C</span><span>Y</span>"
Example 3 source:
"間違<span>う</span>"
Example 3 result:
"<span>間</span><span>違</span><span>う</span>
Example 4 source:
"<span>う</span>間違"
Example 4 result:
"<span>う</span><span>間</span><span>違</span>"
Please note, it's only the characters that do not have a span that I need to add spans to each of. I hope it makes sense. So in the first case "ABCDE" needs to stay as "ABCDE".