Hi Klaus!
On Sun, 02 May 2004 22:46:23 +0200, Klaus Harbo klaus@harbo.net wrote:
I have been using cl-ppcre for quite some time - great program library, thx! - but I am now looking to match multi-line data, and Iøm having some difficulties...
I would expect
(scan (create-scanner ".+" :multi-line-mode t) (concatenate 'string '(#\a #\Newline #\b)))
to match all three characters, but it matches only #\a. I downloaded cl-ppcre from CVS just now to check that this occurs in the most recent version;
I don't really use the CVS repository at common-lisp.net. The most recent version is usually the one available from weitz.de.
I'm using Lispworks 4.3.6. CMUCL 18d seems to behave the same way.
Can I make :everything (".") match multiple lines of input, and if so, how?
What you're looking for is "single-line mode", not "multi-line mode", actually. "single-line mode" means to treat the whole target string as if it were a single line and thus the dot also matches newlines (which it normally doesn't). "multi-line mode" means to treat the whole target string as if it consisted of multiple lines and thus the anchors "^" and "$" also match around newlines in the middle of the string (but see also "\A", "\Z", and "\z"). These two features are orthogonal.
* (scan "(?m).+" "a b")
0 1 #() #() * (scan "(?s).+" "a b")
0 3 #() #()
For the gory details see the Perl documentation, specifically "man perlre" - remember that CL-PPCRE tries hard to be compatible with Perl.
HTH, Edi.