mardi 31 mars 2015

how to filter out a pattern in python regular expressions, till the input word

In python, i want to extract a particular sub string till the input word provided.


Consider the following string:-



"Name: abc and Age:24"


I want to extract the string "Name : abc and" änd "Age:24"seperately. I am currently using the following pattern:



re.search(r'%S+\s*:[\S\s]+',pattern).


but o/p is the whole string.


Aucun commentaire:

Enregistrer un commentaire