|
|
@ -3,12 +3,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define+provide/contract (starts-with? str starter)
|
|
|
|
(define+provide/contract (starts-with? str starter)
|
|
|
|
(string? string? . -> . coerce/boolean?)
|
|
|
|
(coerce/string? coerce/string? . -> . coerce/boolean?)
|
|
|
|
(define starter-pattern (regexp (format "^~a" starter)))
|
|
|
|
(and (<= (string-length starter) (string-length str))
|
|
|
|
(regexp-match starter-pattern str))
|
|
|
|
(equal? (substring str 0 (string-length starter)) starter)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define+provide/contract (ends-with? str ender)
|
|
|
|
(define+provide/contract (ends-with? str ender)
|
|
|
|
(string? string? . -> . coerce/boolean?)
|
|
|
|
(coerce/string? coerce/string? . -> . coerce/boolean?)
|
|
|
|
(define ender-pattern (regexp (format "~a$" ender)))
|
|
|
|
(and (<= (string-length ender) (string-length str))
|
|
|
|
(regexp-match ender-pattern str))
|
|
|
|
(equal? (substring str (- (string-length str) (string-length ender)) (string-length str)) ender)))
|