OT: novice regular expression question

From: It's me (itsme_at_yahoo.com)
Date: 12/30/04


Date: Thu, 30 Dec 2004 17:18:56 GMT

I am never very good with regular expressions. My head always hurts
whenever I need to use it.

I need to read a data file and parse each data record. Each item on the
data record begins with either a string, or a list of strings. I searched
around and didn't see any existing Python packages that does that.
scanf.py, for instance, can do standard items but doesn't know about list.
So, I figure I might have to write a lex engine for it and of course I have
to deal wit RE again.

But I run into problem right from the start. To recognize a list, I need a
RE for the string:

1) begin with [" (left bracket followed by a double quote with zero or more
spaces in between)
2) followed by any characters until ] but only if that left bracket is not
preceeded by the escape character \.

So, I tried:

^\[[" "]*"[a-z,A-Z\,, ]*(\\\])*[a-z,A-Z\,, \"]*]

and tested with:

    ["This line\] works"]

but it fails with:

    ["This line fails"]

I would have thought that:

   (\\\])*

should work because it's zero or more incidence of the pattern \]

Any help is greatly appreciated.

Sorry for beign OT. I posted this question at the lex group and didn't get
any response. I figure may be somebody would know around here.



Relevant Pages

  • REPRESENT revisited
    ... Forth-94 has few floating point display functions [none in the ... If u is greater than zero the character string shall consist ... If u is zero the string shall consist of one digit representing ...
    (comp.lang.forth)
  • Re: Reproducing java calculations in UNIX
    ... quotient goes in x, also a double. ... is greater than zero) only the fractional part of the ... {fraction is 52 zero bits, ... is converted from string to floating point (string ...
    (comp.unix.shell)
  • Re: REPRESENT revisited
    ... >has given rise to implementations that differ in critical ... The required compatibility is 1), but 2) makes it much easier to get ... > If u is zero the string shall consist of one digit representing ... But I think it is a very bad idea if a word that should fill a string ...
    (comp.lang.forth)
  • Re: Allow Zero Length String Property - 2000 vs 2003
    ... Are you the same person who posted the 'Allow Zero Length String in MS ... "Ash" wrote in message ...
    (microsoft.public.access.tablesdbdesign)
  • RE: Macro Question
    ... The string you want Microsoft Excel to search for. ... SearchOrder Optional Variant. ... The settings for LookAt, SearchOrder, MatchCase, and MatchByte are saved ... > include a search for occurrences of zero. ...
    (microsoft.public.excel.programming)

Loading