Regex is definitely the way to go here mainly because this would warn you when something goes unexpected by default (meaning that it will only expect Si/No).
First you need to build a pattern, in our case
"Presenza Vincolo Polizza (Si|No)"
- Text will simply match itself, including the space (Presenza Vincolo Polizza )
- Parentheses will declare a group within the pattern.
- Pipe ("|") is the ‘Or’ operator in Regex.
Using the “Matches” activity in UiPath will accept the pattern above, an input string (the raw text) and will return you an Enumerable of System.Text.RegularExpressions.Matches.
It is advised to check if you have only one match before extracting the result, A simple if will do.
Next step is to access the “Groups” property of the match, which will contain only the part you are interested in (Si/No).
It can be done bellow, We will capture index 1 as the index 0 will represent all the initial pattern matched.
Assign match = regexMatches(0)
Assign strSiNo = match.Groups(1).ToString`
You can find a workflow example here
RegexSiNo.zip (2.5 KB)