How to count the occurence of a sign or string with Regex?

Hi, I want to count the number of commas “,” in a string.
I thought of something like this:
int commaOccurrences = Regex.Matches(myText, “,”, RegexOptions.Multiline).Count
But how do I use that? Invoke Code didn’t work. It showed that Regex is not defined.
Thanks a lot.

Please add the following namespace. Regex are under the following namespace -

System.Text.RegularExpressions

Regards,
Karthik Byggari

2 Likes

Thank you, the Regex problem is solved.

Hi @Jizh,

Please try this -

Regards,
Nitesh

1 Like

use Message box to print the result like this.

1 Like

Edit: The string problem is now solved too. It was my bad, the Arguments in/out in the invoke code activity had string type. Thanks, now I know both ways :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.