Re: Help simplify complex regexp needing positive lookahead and reluctant quantifers

david.karr_at_wamu.net
Date: 03/24/05


Date: 24 Mar 2005 09:10:47 -0800

Ok, the difference between our two was that my sample has "\r\n" for
eols. Once I changed my pattern to check for that explicitly, I get
similar output. I tried some variations with "$" and "(?m)", but it
only got past this if I specifically used "\r\n".

However, now I have to go deeper into this, and the current expression
doesn't quite do what I need.

What I really need to capture in individual groups would be the
following (each group surrounded by brackets):

[YYY=]
[D/23333333
xxxxxxxxxxxx
yyyyyyyyyyyy]
[ZZZ=]
[gggggggggggg]
[AAA=]
[hhhhhhhhhh
jjjjjjjjjjj
kkkkkkkkkkk]

Note that I've removed the initial spaces and dashes. That's my end
state, but I can work to that step by step.

When my code steps through all the groups it found, it finds this:

---------------
group[ YYY=D/23333333
 -xxxxxxxxxxxx
 -yyyyyyyyyyyy
 ZZZ=gggggggggggg
 AAA=hhhhhhhhhh
 -jjjjjjjjjjj
 -kkkkkkkkkkk
]
group[AAA=]
group[hhhhhhhhhh
 -jjjjjjjjjjj
 -kkkkkkkkkkk
]
---------------

I don't care about the first group, because that surrounds all of the
subrecords. I would have hoped that the next group would be "YYY=",
followed by the group with its associated data, and so on.



Relevant Pages

  • Re: Is this C program doing what it is supposed to do ?
    ... Richard started by boiling it down to single letter names. ... advocating against the pattern itself, ... Even inside brackets, it becomes an eysore in some cases: ...
    (comp.lang.c)
  • Re: RegEx
    ... This works for me but if there is a more compact definition, ... your current pattern will match only cases where all the table ... names are in brackets or none of them are. ... and table names that have mixed bracket/no bracket formats: ...
    (microsoft.public.scripting.vbscript)
  • Re: Error in RowFilter Like Operation
    ... characters should be escaped in brackets. ... a pattern, or at the end of a pattern, or at the beginning of a ... "ItemName LIKE '*product'" ... Wildcards are not allowed in the middle of a string. ...
    (microsoft.public.dotnet.framework.adonet)
  • Complex regular expression
    ... Is it possible to write a regular expression for this? ... Pattern: 999-99-999 ... Whatever numbers and dashes he had entered must match the above format, ...
    (comp.lang.perl.misc)
  • Re: RegEx
    ... This works for me but if there is a more compact definition, ... your current pattern will match only cases where all the table ... names are in brackets or none of them are. ... and table names that have mixed bracket/no bracket formats: ...
    (microsoft.public.scripting.vbscript)