string - Python : extract all items that match a pattern -


is there strait forward way in python extract items match pattern, items between 2 characters (for example $$)

i have tried using

split("$""$") 

on string looks

string = "$this$ $is$ $some$ $data$" 

with aim of getting looks this

string = [ $this$, $is$, $some$, $data$ ] 

however doesn't work, there strait forward way extract matches pattern in python?

how following code?

>>> import re >>> s = "$this$ $is$ $some$ $data$" >>> re.findall(r'\$[^$]*\$', s) ['$this$', '$is$', '$some$', '$data$'] 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -