Skip to content

Instantly share code, notes, and snippets.

@xieyuheng
Created November 17, 2015 20:01
Show Gist options
  • Save xieyuheng/ac00b583fef7a1874234 to your computer and use it in GitHub Desktop.
Save xieyuheng/ac00b583fef7a1874234 to your computer and use it in GitHub Desktop.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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