Closed MrinmoyHaloi closed 2 years ago
ctre::search
, ctre::starts_with
, ctre::match
and their multiline variants returns only one set of captures
to obtain multiple, you need to use other API (or multiline variants)
ctre::range<"pattern">
... return forward iterable range which is equivalent of multiple calls of ctre::search (each time on remainder of the result)
ctre::tokenize<"pattern">
... equivalent to ctre::starts_with
multiple time (same as with ctre::range
)
there are also
ctre::iterator<"pattern">
which returns directly the iterator for matching (same as one obtained from .begin()
in ctre::range
result)
and
ctre::split<"pattern">
which returns range of ranges delimited by the pattern
example for ctre::range
: https://compiler-explorer.com/z/vn5x8b1zf
I want to know how can i get all occurrences of a search. If i use normal search functions it only gives the first occurrence.
My code:
str is a file with the following content:
The code currently outputs this:
func name(){%
What i am expecting:
I have tested the regex in javascript with the global flag and it works perfectly.