is there any way i can show more than 1 match on my uipath as currently it only shows the first match
For that you can use Matches activity OR Matches method with following method in assign activity,
matches = System.Text.RegularExpressions.Regex.Matches(StringVar,"RegexPattern")
here matches var in left side of assign —> should be of type
StringVar —> is of type System.String, holding input string,
don’t forget to put regex pattern in quotes. here —> “RegexPattern”
to display each value… we need For Each activity, specify metaches var in it with type argument as
inside messageBox with value as —> item.ToString
here’s workflow screenshot for your better understanding.
it does not really work as i have tried.
this is my workflow can you help to see whats wrong.Sequence.xaml (19.2 KB)
- you have used StringVar as it is
You should use your input string variable no.
- matches variable should be of type `System.Text.RegularExpressions.Match —> MatchesCollection
@Kian, I’ll suggest you to check this sample workflow, check input, run it and check output, you’ll get exact idea that how it works.
Test1.xaml (6.3 KB)
Then use your only 1 input with your regex pattern and check for output, if it works good, then use above logic in your workflow.
Hello @Kian ,
You should use Multiline option. By the way, a lookbehind with variable character number seems fishy… could you please try the following?:
pattern = "^.+?(?=\s-)"
matches = Regex.Matches(myText, pattern, RegexOptions.Multiline)
matches(element type is