Like this:
Regex.Matches("0129384927377","7").Count
Question
I am working in C#
I want to be able to call a function on a specific character in my regular expression language and was wondering if this was possible. For example if I have my pattern as ^[0-9]*$
I would like to call the function foo()
when a 7 is found. So if I had the string "0129384927377"
it would call the function foo
three times.
Any way of doing this?
If you want context I'm trying to build a DPDA (Deterministic Pushdown Automaton) as simply as possible and not sure the best way of doing it.
Solution
Like this:
Regex.Matches("0129384927377","7").Count