in reply to Re: Re: Re: Regular Exp parsing
in thread Regular Exp parsing

Hi Mark,

That's great information. I didn't know that \n would not be literraly matched when using $ as an anchor. I normally chomp all my strings before they get to that point so I hadn't encountered it. Knowing this now though is there a reason as to why? Does $ assume EOL characters?

BTW - Did you mean to put a \z in your initial example?

Dave -- Saving the world one node at a time

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Regular Exp parsing
by MarkM (Curate) on Dec 13, 2002 at 21:49 UTC

    The $ thing is due to legacy behaviour, and the fact that when most people say $, they mean "end of string, or end of line, but not the end of line itself." There is no question that $ is one of the most useful regexp primitive operators there is. Just, people are very comfortable with using it, and so, sometimes it gets used in places where it is questionable to use, or very rarely, in places where problems can arise.

    In my initial example, I used ':' instead of '\z', because the original example looked as if the year was trailed with a ':' and since I didn't know exactly what was after the ':', I figured it would be simpler to just not care, and align the regexp based on the ':'. In the original example, the ':' may have been a typo, in which case I probably would have used \z as you suggest.

    Cheers,
    mark