[Haskell-cafe] Re: ANN: weighted-regexp-0.1.0.0
sebf at informatik.uni-kiel.de
Wed Jul 28 16:38:23 EDT 2010
>> 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
> lines much easier to control. But anchors are also a source of bugs
> 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
Underestimating the novelty of the future is a time-honored tradition.
More information about the Haskell-Cafe