I'm having a text of this format:
a=b, // c=d f=0x83 t= "some_string"
and would like to go over it using regex pattern so each time i take the left-operand and the right operand of the "=" ie i want to extract first "a" and "b" then "c" and "d" etc...
I tried this regex:
".+=.+"
But the right operand give the rest of the sentence instead of only "b".
If your data does not contain the empty string values and the characters from these - ",", " ", "/", then you can do this:
import re
s = 'a=b, // c=d f=0x83 t= "some_string"'
ss = re.split(r'[= ,/]', s)
print(ss)
sss = [x for x in ss if x != '']
print(sss)
['a', 'b', '', '', '', '', 'c', 'd', '', 'f', '0x83', 't', '', '"some_string"']
['a', 'b', 'c', 'd', 'f', '0x83', 't', '"some_string"']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.