Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Re: Match text between two words

  •  12-10-2007, 6:52 PM

    Re: Match text between two words

    Ok, real data (but sorry, cannot give you real person names).

    I will use TRegExpr for Delphi to process old ascii files with person names (code 720, plus name) optionally followed by the profession (code 100, plus profession name).

    ...| 720 | John Doe | 720 | Winston Smith | 720 | Peter Parker | 100 | Journalist | 720 | Humpty Dumpty | 720 | ...

    You see that many names are not followed by a corresponding profession, only 720|Peter Parker has a 100|Journalist.

    It seems that to match the names that have a profession defined, it's enough to locate when a 720 code is immediatly followed by a 100 code.

    So you must match:
        720 | Peter Parker | 100 | Journalist

    However you must not match:
        720 | Winston Smith | 720 | Peter Parker | 100 | Journalist  

    because the first 720 is not immeadiatly followed by a 100, there is another 720 in between. Or, if you prefer, there is a sequence "720|name" repeated

    within the match.

    I've tried to avoid repetitions with (720.*\s*){1}100\s*.* but unlucky. How do I exclude the 720|name repetition?

    Is RE suitable for this problem? Or will be easier programatically, with Delphi code?

    Thanks again

    Filed under: ,
View Complete Thread