Q:

regex: match all characteres between 2 words, returns strange output

in this text:
"IPAddress":"10.0.0.18","PolicerID":"","IPAddress":"","PolicerID":""

I want to catch all ips, in this example are 10.0.0.18 and emptystring
I tried to use this regex:

(?<="IPAddress":")(.*?)(?=")

which returns me 10.0.0.18 and ",
it took the first " from PolicerID instead of the last " in IPAddress.
Can you please help me?
Thanks

A:

You can keep it simple and just use a capturing group:
>>> str = r'"IPAddress":"10.0.0.18","PolicerID":"","IPAddress":"","PolicerID":""'
>>> print re.findall(r'"IPAddress":"([^"]*)', str)
['10.0.0.18', '']
>>>

However if you have to use lookbehind assertion then use this regex:
(?<="IPAddress":")([^"]*)

([^"]*) is a negated pattern to match 0 or more of any character that is not a double quote.
RegEx Demo

