'Regex get matched and unmatched parts

I have a string that would containing and tags. I know parsing HTML with Regex is not a good option but here since I would only be getting a handful of tags from a WYSIWYG editor, I am using this approach.

What I want to achieve is split the string into ordinary text and tags. E.g.:

string str = "Hi I am normal text <strong>but bold</strong> and normal again";

I want the output to be:

[Hi I am normal text,
<strong>but bold</strong>, 
and normal again]

So far I have tried both Regex Split and Match using a combination of various expressions like (<[^<>]*>), <([^.>]+).*\s*\1> and <\s*([^.>]+)[^>]*>.*?<\s*/\s*\1\s*> but none of these seem to work



Solution 1:[1]

A simple .decode("utf-8") would do

import base64
string = base64.b64encode(bytes("string", 'utf-8'))
print (string.decode("utf-8"))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sriram Sitharaman