Handbook
Glossary
count-matches ( string regexp -- n )
Regular expressions
ยป
Matching operations with regular expressions
Prev:
first-match ( string regexp -- slice/f )
Next:
all-matching-slices ( string regexp -- seq )
Vocabulary
regexp
Inputs
string
a
string
regexp
a
regexp
Outputs
n
an
integer
Word description
Counts how many disjoint matches the regexp has in the string, as made unambiguous by
all-matching-slices
.
Definition
USING:
kernel
math
;
IN:
regexp
:
count-matches
( string regexp -- n )
[
0
]
2dip
[
3drop
1
+
]
each-match
;