nitin saxena nitin saxena - 25 days ago 10
Python Question

split string with equal sign at any location using python

I would like to split string with equal sign at any location.

[In] This is a example string abc=xyz this is a example string


Can somebody please tell me how to print all the string after the equals to sign ("="). For instance, in the above case, output should be

[Out] abc=xyz


I got some clue how to split if ('=') if its in last word but not in anywhere inside string.

Answer

findall to find all the occurances, (I assumed that was your requirement)

import re
a = "[In] This is a example string abc=xyz this is a example string"
print(re.findall("\w+=\w+",a))

OP

['abc=xyz']

Comments