We’re trying to count number of ampersands in a string efficiently using Regex. I know I can count them, by iterating, I need it in Regex form due a framework requirement.
Is there someone who could provide a regex that just counts internally? That is it doesn’t actually do any matching other than that. Or minimal matching and saving of the matches.
Let me clarify, counting is not an option, we need a Regex. Put simply, I have a string I read from a file, I dynamically pass that to a library I don’t have code for. And therefore need a regex
I’m not sure what your framework requirement is necessitating the use of regex, but here’s a simple linq solution in case it’s of value to you.
EDIT
Regex version: