Using Contains on part of a word

Hi all,

I am using Contain to search for part of a word

For example I have a string with text like RPAFirstJobRun and I want to search for part of this text.

I have used Var.ToString.Contains(“RPAFirst”) but this doesnt work as Contains seems to search for complete words and not part of a word.

The text may change in length or content, so I just need to search for “RPAFirst” in whatever is in the string.

Thanks for any help

1 Like

HI @MattRPA2019,

The contains will search the required text in a string wherever it is available in the string and it will return a Boolean output.

Can you show how you are using it, screenshot of the process.

RPAFirst

I am just reading in a string (item.ToString) and checking if it contains “RPAFirst” and if it does, is assigns text to the Job Order row.

Its just the contains appears to need exact match, rather than search part of a word. Is there a way to use RegEx to search part of a word?

Not string.IsNullOrEmpty(Var) and Var.ToString.Contains(“RPAFirst”)

Try this…! @MattRPA2019

Thanks!

The total string text is RPAFirstJobRun and the Contains only seems to work if the RPAFirst is all of the word, not part of it.

Hi ,
I can see that you are using for each loop
If the list or array that your are iterating through is of string type , don’t forget to change for ecah loop argument type to string
First please check whether item is having any value or not
If Not string.isnullorempty(item) and string.tolower.trim.contains(“rpafirst”)

whenever you use contains method
Please use as
String.tolower.trim.contains(“rpafirst”)
This will eliminate mismatch issues due to case sensitive and spaces

The table is full so no null but I added that anyway. set the ToLower.trim and searched again and did not work.

Are you using for each row loop OR For each loop ?
Since you said table , you better use for each row loop

Using an Each Row Loop.

Okay , once you use for each row loop
Inside the loop , you might be using get row item activity to read a particular column value in whichever the column you are thinking the data will be “RPAFirstjob”
For this get row item activity the output will be string variable ex: str1
Now use if condition
If
Str1.trim.tolower.contains(“rpafirst”)
Then

2 Likes

OK so this has worked. My String was actually an array, so once I set this to a string variable, and added the ToLower, my match has wored.

Thanks @vinay_reddy

1 Like

Np , happy to help here
Happy Automation
Cheers

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