[plt-scheme] unexpected regexp behaviour

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Jun 15 22:11:19 EDT 2008

On Jun 15, Martin DeMello wrote:
> On Sun, Jun 15, 2008 at 6:46 PM, Eli Barzilay <eli at barzilay.org> wrote:
> >
> > This consistent with (and a result of) the way `regexp-match'
> > works when you begin in the middle of the string:
> >
> >  > (regexp-match #rx"(?m:^..)" "hello" 2)
> >  ("ll")
> >  > (regexp-match #px"\\b.." "hello" 2)
> >  ("ll")
> So how do I match, say, the first letter of every line in a
> multiline string?

In most cases I'd probably split the string up into lines, which
simplifies most later processing anyway.  If memory is an issue, then
you can use a (?<=\n) anchor in `regexp-match*', and a separate match
for the first line.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.