I have a string which can be of the form:
s1 = "Hello HAHA"
s2 = '["Hello HAHA"]'
s3 = "{Hello HAHA}"
I want to find out if the input string is like s1, s2 or s3. My motive is to sanitise this input and save it in s1 format.
Basically I need to know if the input string is in s1 form or not.
Solutions I have thought of:
json.loads(s)and catch exception to check if it is a json or not- Regex search to see if the input string has
{|}|[|]in it in the starting and end position, and replace them.
What will be the most pythonic way to go about it?
s3, nots2. That is where the bigger problem is @jsfan