@elya - i don’t quite understand what you’re trying to achieve with your example as it’s a bit unclear. However, i can answer this part:
Extras: What is the syntax to add multiple regexOptions in UiPath?
You need to use an OR statement. So it would be Regex.IsMatch(StringToCheck,RegexPatternAsString,RegexOptions.IgnorePatternWhiteSpace Or RegexOptions.IgnoreCase)
@elya - i am not able to open .7z files as i can’t download new applications, it’d have to be .zip instead.
However, why do you want to use the ignorepatternwhitespace option? What is wrong with using \s? that is a lot more simple I’d imagine. Just use the following expression if there is a possibility for no whitespace: ELY\s*A or ELY\s+A if you only want to find matches where there is at least 1 whitespace. Both patterns will pull out any type of whitespace character no matter how many there are between the ELY and the A
@elya the 2 expressions above (one with asterisk * and one with plus +) both do exactly what you’re asking? Is there a reason why the expression will not work for you that I am misunderstanding? If so, perhaps you could give a sample input text and your expected result you want to pull out with regex. We’d need something longer than what was provided as sample input text in the first post though
@Palaniyappan your example will not capture the letter A and will also capture all the garbage (any character, not just whitespaces) in the entire input string between ELY and the next letter A, even if it isn’t what the OP was hoping to get
Based on your input text and your expected output I don’t think Regex is the best solution. I would instead use string.split
If the text you want is always going to be preceded by ELECTRICITY DELIVERY IBAN : then you should split on that text, take the 2nd string in the array, and trim it. That would give you your desired answer of “GB36 DEUT 3636 3737 3838 00”. If you want to remove the spaces, just use a .Replace(" ",string.empty) on this string
This assumes the preceding text is always constant, and you want to pull out all of the text afterwards. You’d have to make a few changes if either of these assumptions are incorrect
I dont want to remove space. I want to find "GB36 DEUT 3636 3737 3838 00”
from "GB36DEUT36363737383800”, and this 1 of 100 account i ve to find. And all of them could be like that: “GB36DEUT363637 37383800”
“GB36DEUT36363737383
800”
“GB 36 DEUT 3636 3737 3838 00”
All of this information is needed for us to help. The more information you provide, the easier it is for us to help with a solution.
It sounds like you have a list of strings, and you are trying to find matches for each string in that list within the Input Text. Is that correct? If so, I’d go about it like this.
Clean up the input text to remove spaces. Create a new string called InputStringNoSpaces and use an assign activity as follows: Assign InputStringNoSpaces = new String(InputString.Where(Function (x) Not Char.IsWhiteSpace(x)).ToArray())
Create a new list of strings i’ll call MatchedStrings. Assign MatchedStrings = new list(of string)
For each str in MyListOfStrings
a. If InputStringNoSpaces.ToUpper.Contains(str.ToUpper) Then add str to MatchedStrings collection (use add to collection activity)
Now you have a list of all the strings that were matches.
If you don’t have a list of all the strings you’re trying to match then we would do something else. I’m having to make a lot of assumptions because we are being provided very limited information.
If you just want to pull out from InputText all of the items that look like they are IBANs, then it appears they all follow the same pattern. I would do it as follows:
Remove all the spaces from InputText like we did in step #1 above
Assign IBANmatches (this is an ienumerable matches variable) = Regex.Matches(InputText,"[A-Za-z]{2}\d{2}[A-Za-z]{4}\d{14})
Assign IBANnumbers = new list(of string)
For each IBAN in IBANmatches
a. add to collection activity (TypeArgment string): IBAN.value
Now you have pulled out all IBANs from the input text. This assumes it follows the pattern specified in the regex expression
@elya that just ignores whitespace in your pattern, it doesn’t ignore whitespace within the InputText. It’s generally only used if you have a complex regex pattern and you use whitespace to help make it more readable. It’s very rarely used in my experience, because if your regex is that complicated, it should probably be broken down into multiple regex anyways