Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
#lang at-exp racket
|
||||
|
||||
(define comment-start-rx "[;#]")
|
||||
|
||||
(define text
|
||||
@~a{apples, pears # and bananas
|
||||
apples, pears ; and bananas
|
||||
})
|
||||
|
||||
(define (strip-comments text [rx comment-start-rx])
|
||||
(string-join
|
||||
(for/list ([line (string-split text "\n")])
|
||||
(string-trim line (pregexp (~a "\\s*" rx ".*")) #:left? #f))
|
||||
"\n"))
|
||||
|
||||
;; Alternatively, do it in a single regexp operation
|
||||
(define (strip-comments2 text [rx comment-start-rx])
|
||||
(regexp-replace* (pregexp (~a "(?m:\\s*" rx ".*)")) text ""))
|
||||
|
||||
(strip-comments2 text) ; -> "apples, pears\napples, pears"
|
||||
Loading…
Add table
Add a link
Reference in a new issue