On Sat, Mar 01, 2008 at 04:21:16AM -0700, Matthew Welland wrote: > What am I not getting here? > > DB<1> "\\foo "=~m/^\\(.*) $/;print $1; > foo > > irb> "\\foo ".match(/^\\(.*)\s*$/);puts $1 > foo > > csi> (string-match (regexp "^\\(.*)\\s*$") "\\foo ") > #f
It tells me
Error: (regexp) cannot compile regular expression - unmatched parentheses
In chicken, you're doing the equivalent of Ruby's
"\\foo ".match(/^\(.*)\s*$/)
So, to get two backslashes in the string, use four of them;
one to escape the first, one to escape the second, resulting in
two backslashes which count for the regex as one escaped backslash.
#;2> (string-match (regexp "^\\\\(.*)\\s*$") "\\foo ")
("\\foo " "foo ")
HTH,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
pgpDYmNCEN1FM.pgp
Description: PGP signature
_______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
