Re: multiple pattern regular expression

2008-04-28 Thread micron_make
each of the suggested methods fit in. I have started trying them. -Rohit -- View this message in context: http://www.nabble.com/multiple-pattern-regular-expression-tp16895148p16936657.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org

Re: multiple pattern regular expression

2008-04-25 Thread Arnaud Delobelle
Chris Henry <[EMAIL PROTECTED]> writes: > On Apr 25, 8:37 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> micron_make <[EMAIL PROTECTED]> writes: >> > I am trying to parse a file whose contents are : >> >> > parameter=current >> > max=5A >> > min=2A > [snip] >> If every line of the file is of t

Re: multiple pattern regular expression

2008-04-25 Thread Chris Henry
On Apr 25, 8:37 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > micron_make <[EMAIL PROTECTED]> writes: > > I am trying to parse a file whose contents are : > > > parameter=current > > max=5A > > min=2A [snip] > If every line of the file is of the form name=value, then regexps are > indeed not ne

Re: multiple pattern regular expression

2008-04-25 Thread Nick Stinemates
On Fri, Apr 25, 2008 at 08:40:55PM -0400, Carsten Haese wrote: > Nick Stinemates wrote: >> On Fri, Apr 25, 2008 at 09:50:56AM -0400, [EMAIL PROTECTED] wrote: >>> How about this? >>> >>> for line in file: >>> # ignore lines without = assignment >>> if '=' in line: >>> property, value

Re: multiple pattern regular expression

2008-04-25 Thread Carsten Haese
Nick Stinemates wrote: On Fri, Apr 25, 2008 at 09:50:56AM -0400, [EMAIL PROTECTED] wrote: How about this? for line in file: # ignore lines without = assignment if '=' in line: property, value = line.strip().split( '=', 1 ) property = property.strip().lower() valu

Re: multiple pattern regular expression

2008-04-25 Thread Nick Stinemates
On Fri, Apr 25, 2008 at 09:50:56AM -0400, [EMAIL PROTECTED] wrote: > How about this? > > for line in file: > # ignore lines without = assignment > if '=' in line: > property, value = line.strip().split( '=', 1 ) > property = property.strip().lower() > value = value.

Re: multiple pattern regular expression

2008-04-25 Thread python
How about this? for line in file: # ignore lines without = assignment if '=' in line: property, value = line.strip().split( '=', 1 ) property = property.strip().lower() value = value.strip() # do something with property, value Malcolm -- http://mail.python

Re: multiple pattern regular expression

2008-04-25 Thread Robert Bossy
Arnaud Delobelle wrote: micron_make <[EMAIL PROTECTED]> writes: 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 patt

Re: multiple pattern regular expression

2008-04-25 Thread Arnaud Delobelle
micron_make <[EMAIL PROTECTED]> writes: > 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 reg

multiple pattern regular expression

2008-04-25 Thread micron_make
ing 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/multi