regex - python finding multiple occurrences between 2 delimiter -


i'm trying find multiply occurrences between 2 delimiters using regex. unfortunately can't figure out how. 2 delimiters ' , ':

import re string = "'lightoff' 'lighton':,'lightoff' 'ovenoff' 'ovenon': none 'radioon': 'radiooff'" print string print 'newstring', re.findall("^'(.*?)':", string) 

i first match

'lighton' 

what want 3 substrings between ' , ':

'lighton' 'ovenon' 'radioon' 

do not use anchor. ^ , $ anchors in regex pattern. also, when match between 2 ', it'll return string 'word1' 'word2': output, instead of 'word2':. try match between 2 ' isn't character ' itself.

re.findall("'([^']+)':", string) 

will work.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -