I’m a newbie to regular expressions and I have the following string:
sequence = '["{\"First\":\"Belyuen,NT,0801\",\"Second\":\"Belyuen,NT,0801\"}","{\"First\":\"Larrakeyah,NT,0801\",\"Second\":\"Larrakeyah,NT,0801\"}"]'
I am trying to extract the text Belyuen,NT,0801 and Larrakeyah,NT,0801 in python. I have the following code which is not working:
re.search('\:\\"...\\', ''.join(sequence))
I.e. I want to get the string between characters :\ and \.
Don’t use regex for this. It appears to be a rather strangely split set of JSON strings. Join them back together and use the
jsonmodule to decode it.(Note the json module is new in Python2.6 – if you have a lower version, download and install simplejson).