diff --git a/collects/unstable/scribblings/string.scrbl b/collects/unstable/scribblings/string.scrbl index d695ddea9c..f6c76c0d79 100644 --- a/collects/unstable/scribblings/string.scrbl +++ b/collects/unstable/scribblings/string.scrbl @@ -27,3 +27,12 @@ string?]{ @racket[write]s @racket[v] to a string and returns it. } + + +@addition{Vincent St-Amour} + +@defproc[(regexp-filter [pattern (or/c string? bytes? regexp? byte-regexp?)] + [lst (listof (or/c string? bytes? path? input-port?))]) + (listof (or/c string? bytes? path? input-port?))]{ +Keeps only the elements of @racket[lst] that match @racket[pattern]. +} diff --git a/collects/unstable/string.rkt b/collects/unstable/string.rkt index 9fed06bbcb..1f80ff3930 100644 --- a/collects/unstable/string.rkt +++ b/collects/unstable/string.rkt @@ -33,3 +33,14 @@ [lowercase-symbol! ((or/c string? bytes?) . -> . symbol?)] [read/string (string? . -> . serializable?)] [write/string (serializable? . -> . string?)]) + + +;; added by stamourv + +(define (regexp-filter r log) + (for/list ([l (in-list log)] #:when (regexp-match r l)) + l)) +(provide/contract + [regexp-filter ((or/c string? bytes? regexp? byte-regexp?) + (listof (or/c string? bytes? path? input-port?)) + . -> . (listof (or/c string? bytes? path? input-port?)))])