There was another thread about regexp-match lately, and it made me
think of a couple things I wish were available

It would be great if Perl's / pcre's "x" mode could be pulled into
Racket, ideally with modifiers on the end of the regexp instead of
inside it.  This mode specifies that all whitespace in the pattern
should be ignored, so if you want to actually match whitespace then
you need to specify it.  Example:

; tokenizer code running under the at-exp sublanguage: match a word
boundary, 'var', whitespace, one or more contiguous word characters
(ASCII alphanumerics or _), and then another word boundary

@pregexp{\b var \s+ \w+ \b}x

Oh, and if I'm already asking for the moon, does Racket have any
equivalent to Perl's named captures or composable regexen, or any
possibility of adding them?

(regexp-match @px{\b(?<greet>hi|hello)} "hi bob")
(println greet) ; prints "hi"

(define bar #px"(bar)")
(regexp-match @px{(foo)@bar} "foobar") ; equivalent to
@px{(foo)(bar)}. returns '("foobar" "foo" "bar")

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to