I have this string: 'foo = bar; this = is; not = necessary'
I would like to get this result: {"name" : "foo", "value" : "bar"}
It is not necessary, what is after the ;
I know, I should use some regexp, but I don’t really understand how regexp works.
Thanks is advance,
You could use:
This way you do:
'foo = bar; this = is; not = necessary'.split('; '), which returns['foo = bar','this = is','not = necessary']'foo = bar; this = is; not = necessary'.split(';')[0]gives'foo = bar''foo = bar; this = is; not = necessary'.split(';')[0].split(' = '), which gives['foo','bar']