REG_NEWLINE   Compile for newline-sensitive matching.  By default,
newline is a completely ordinary character with no special meaning in
either REs or strings.  With this flag, `[^' bracket expressions and
`.' never match newline, a `^' anchor matches the null string after
any newline in the string in addition to its normal function, and the
`$' anchor matches the null string before any newline in the string
in addition to its normal function.

Using ^ and $ to match near newlines makes matching patterns that cross lines much easier to control. But anchors are also a source of bugs for
some implementations, e.g. libtre.

Maybe I underestimated the utility of ^ and $. The definition seems intricate. I thought about adding a combinator for matching newline but now think that would lead to wrong start and end positions. For example the start position of the matching substring for ^a in "a \na" should be 2 not 1, right? Or is it 0 although there is no newline at the beginning?

Is there a page with examples that show how ^ and $ should behave exactly?

Sebastian

--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to