Get second Occurrence of a String with wildcard

Hello UI Developers,

Can you help me with finding second Occurrence of a “compound wildcard string” in a string variable.

The compound wildcard string looks like * Ravi * hotaliya *
Where * can be any no. of Charachters.

My trials:

  1. I tried with string.contains but .contains doesn’t support wild cards.
  2. I tried to use IndexOf, but it also doesn’t support wildcards.
  3. I tried to use like operator but its returns a boolean saying just that the Compound WildCard String is present but doesn’t say anything about its second occurrence.

Did you try with MATCH Activity ? / REGEX expression ?

Ok so tried is match activity and formed a RegEx. But the issue is it just returns weather the wildcard string is present or not. Any idea how to know if second occurrence is present or not?

so , you are actually looking for number of times (count) Particular string ?

Let me say your output from REGEX expression is “iEnumResult” …(variable type:IEnumrable)

go to Assign.

count = iEnumResult.count

you were almost done
we can use SPLIT METHOD on this
if the input string is
str_input = " * Ravi * hotaliya *"

then use this expression
arr_split = Split(str_input,"*")
–now use a IF condition like this
arr_split.Count > 2
if true it will go to THEN part where we can use a message box like this
“there is second occurence of *”

Cheers @Ravi_Chotaliya


Thanx! for the help. But the string " * Ravi * hotaliya * " Occurs for multiple times in a large paragraph and this paragraph the string variable where occurrence needs to be counted.

BTW I’ve found the solution I’ll mark it in next comment.

Is match returns a boolean. You want to use the Match function of regex instead. Just use an assign activity - system.text.regularexpressions.match(YourString,RegexPattern,OptionalRegexOptions

If you provide some sample input text and what your expected output is i’d be happy to help with the regex pattern. It should be relatively quick/simple based on what you’ve mentioned so far

1 Like

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