multiple pattern regular expression
micron_make
micro_passion at yahoo.com
Fri Apr 25 08:30:18 EDT 2008
I am trying to parse a file whose contents are :
parameter=current
max=5A
min=2A
for a single line I used
for line in file:
print re.search("parameter\s*=\s*(.*)",line).groups()
is there a way to match multiple patterns using regex and return a
dictionary. What I am looking for is (pseudo code)
for line in file:
re.search("pattern1" OR "pattern2" OR ..,line)
and the result should be {pattern1:match, pattern2:match...}
Also should I be using regex at all here ?
-rohit
--
View this message in context: http://www.nabble.com/multiple-pattern-regular-expression-tp16895148p16895148.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list