Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -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)))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(defn count-substring1 [txt sub]
|
||||
(/ (- (count txt) (count (.replaceAll txt sub "")))
|
||||
(count sub)))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(defn count-substring2 [txt sub]
|
||||
(-> sub
|
||||
(re-quote)
|
||||
(re-pattern)
|
||||
(re-matcher txt)
|
||||
(.results)
|
||||
(.count)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue