Created
November 17, 2015 20:01
-
-
Save xieyuheng/ac00b583fef7a1874234 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(regexp-match-positions | |
(regexp | |
(cat | |
((object-name (regexp "needle"))) | |
(" ") | |
((object-name (regexp "needle"))))) | |
"hay needle needle stack") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(define/match (rx-help x) | |
[((? string? x)) x] | |
[((? regexp? x)) (object-name x)] | |
[((? pregexp? x)) (object-name x)] | |
[(_) (orz ("* rx fail >_<\n") | |
(" the following argument can not be used to build regexp\n") | |
(" ~a" x))]) | |
(define (rx . rx-list) | |
(regexp (apply string-append (map rx-help rx-list)))) | |
(regexp-match-positions | |
(rx | |
(rx "needle") | |
" " | |
(rx "needle")) | |
"hay needle needle stack") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment