[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Syntactic sugar for regular expressions and URIs
From: |
Zbigniew |
Subject: |
Re: [Chicken-users] Syntactic sugar for regular expressions and URIs |
Date: |
Wed, 27 Jun 2007 13:10:27 -0500 |
Arto,
How about this patch, which extends your syntax to allow arbitrary delimiters?
#;6> ,x #r/\/path\/to\/file:i
(regexp "/path/to/file" #t #f #f)
#;6> ,x #r:/path/to/file:i
(regexp "/path/to/file" #t #f #f)
#;6> ,x #r{/path/to/file}i
(regexp "/path/to/file" #t #f #f)
#;7> (string-split-fields #r:[^/]+: "/path/to/file")
("path" "to" "file")
#;10> (string-match #r/\/path\/to\/file/ "/path/to/file")
("/path/to/file")
#;8> (string-match #r:/path/(to)/file: "/path/to/file")
("/path/to/file" "to")
The drawback over Perl is that nestable delimiters don't nest, so
#r(hi(bye)) is not valid; you have to escape the parentheses with
backslash, or use a different delimiter if you want grouping.
On 6/27/07, Arto Bendiken <address@hidden> wrote:
First, the `regex-literals' egg [2] provides precompiled regular
expression literals of the
form `#/[a-z0-9]+/i', the Perl-like #/.../[ixu] syntax sure to be
instantly familiar to most everyone:
regex-delim.txt
Description: Text document