Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,10 @@
(defn re-quote
"Produces a string that can be used to create a Pattern
that would match the string text as if it were a literal pattern.
Metacharacters or escape sequences in text will be given no special
meaning"
[text]
(java.util.regex.Pattern/quote text))
(defn count-substring [txt sub]
(count (re-seq (re-pattern (re-quote sub)) txt)))

View file

@ -0,0 +1,3 @@
(defn count-substring1 [txt sub]
(/ (- (count txt) (count (.replaceAll txt sub "")))
(count sub)))

View file

@ -0,0 +1,7 @@
(defn count-substring2 [txt sub]
(-> sub
(re-quote)
(re-pattern)
(re-matcher txt)
(.results)
(.count)))