String manuplation

Hi,

In a for each loop i use a get text activity. The data from get text goes through several if statements. In my workflow i look for the words
“Mobilisation: No” . Sometimes there is space between the colon and sometimes there is no space eg- “Mobilisation:No”.

I currently write the if statement this way

GetTxtVar.ToUpper.Contains(“MOBILISATION: N0”)

Q. How to i wtite my if statement which satisfies both the conditions ?

@RACHEL_PAUL

You can use regex match

System.Text.RegularExpressions.Regex.Match(str,"MOBILISATION:\s+NO",RegexOptions.IgnoreCase)

cheers

Thanks for your response.

Incase i have a sentence
Eg: “HAUL FIBRE AVAILABLE”

someimes there is unrequired space between them or no space.
How do i write my if statement then?

@RACHEL_PAUL

In the above expression change the mobilisation part to this

"HAUL\s*FIBRE\s*AVAILABLE"

System.Text.RegularExpressions.Regex.Match(str,"HAUL\s*FIBRE\s*AVAILABLE",RegexOptions.IgnoreCase)

cheers

Hi Anil

In which Activity do i write this?

System.Text.RegularExpressions.Regex.Match(str,“HAUL\sFIBRE\sAVAILABLE”,RegexOptions.IgnoreCase)

HI @RACHEL_PAUL

Use this expression in the if condition directly

System.Text.RegularExpressions.Regex.IsMatch(Inputstr,"MOBILISATION:NO|MOBILISATION:\s+NO",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

Hope this Helps!

Regards
Sudharsan

@RACHEL_PAUL

Please use it in if condition

System.Text.RegularExpressions.Regex.IsMatch(str,"HAUL\s*FIBRE\s*AVAILABLE",RegexOptions.IgnoreCase)

Cheers

@RACHEL_PAUL

same as above directly in if

System.Text.RegularExpressions.Regex.IsMatch(Inputstr,"HAUL\s+FIBRE\s+AVAILABLE|HAULFIBREAVAILABLE",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

What does\s* mean or \s and also this symbol ‘|’?

\s - will match the spaces

\s+ or \s* - multiple spaces

| - This is the Or symbol

@RACHEL_PAUL

Regards
Sudharsan

Thank you it works !

Hi Sir
Can you say
how to taking date from excel and finding the previous date in UiPath

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