Peter Bex wrote:
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 ")
Disclaimer: I'm still rather new to Chicken, etc, but it seems to me that things
would be clearer using a regex-literal:
#;6> (use regex-literals)
; loading /usr/local/lib/chicken/3/regex-literals.so ...
#;7> (string-match #/^\\(.*)\s*$/ "\\foo ")
("\\foo " "foo ")
Of course the .* match is greedy, so it matches any spaces after "foo" as well,
which may or may not be your (Matthew's) intention. If not, this might work:
#;8> (string-match #/^\\(.*?)\s*$/ "\\foo ")
("\\foo " "foo")
--Hans
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users