Check in String if Contains Keywords

Hi,

I have two strings as shown below:

string1 = POUS45558534
string2 = POUSE8923999

If the string starts with POUS then do action A;
If string starts with POUSE then do action B

I cannot do string.contains(“POUS”), as both string contains “POUS”.

Can anyone help please?
Thanks!

Hi @Yudhisteer_Chintaram1

you can use the function: Startswith.
YourStringVariable.Startswith(“POUSE”) then do A else if YourStringVariable.Startswith(“POUS”) then do B

Best regards
Mahmoud

@Yudhisteer_Chintaram1

You cannot use the CONTAINS function as it agrees to both of your condition. But we can do a trick by placing string.contains(“POUSE”) first then check for string.contains(“POUS”).

Else

You can use AND operator.
string.contains(“POUS”) AND (Not string.contains(“POUSE”))

@Yudhisteer_Chintaram1 - Are you ok with Regex solution ?

image
image

You can regex.ismatch or "Is Match " activity …

Hope this helps…

2 Likes

Hi @prasath17 ,

Can you elaborate more on this regex solution, please? I am not that proficient in it.
Actually, I have more strings to check starting with other characters as shown below:

image

Nopes this one does not work

Please see the attached file.
Sequence32.xaml (5.6 KB)

@Yudhisteer_Chintaram1 - Looks like this is little different than your initial sample…

I can see three variations here… POUS, POUSE, POUSW…Please let us know how do you want to handle these cases??