I have data in notepad, and I need to check if that data contains some strings, if it’s it is 1 or 2 I can use if else but there are many such
strings I need to check 1 by 1 So better to go for switch case
I can use string.contains in condition , but and in cases I can pass expected strings
but I am unable to write complete condition and how to mention those strings? in array ? or list ?I ant it to be more dynamic i should be able
to add more later
samples are
I like RPA
UNKNOWN FORMAT IB/K
PLEASE CHECK AGAIN
RETRY AFTER SOME TIME
such 7 are there, can I add these in asset or in code ?
The best way to start is to describe first your use case as there might be some other approach aside from searching partial strings with .contains from those line of strings. Are the actions to be done if any of your search string is found the same? More details would help in finding how to handle the use case
Hie @Shruthika_r if i’m not wrong and the way i’m understanding you want to use switch condition and check for multiple cases if yes i’m tagging a screenshot for handle multiple
cases. cheers and happy automation.
i need to check if input string ( notepad content with 20 25 lines) contains those substring or no ? if it contains then I need to throw Business exception. I got the result using if else and contains but no BE msgs are more 6 to7, so thought to use switch case instead if else
If that is the case, any of the found string will just result to throwing a business exception then that is achievable. Assign your search string into an array
arraySearchString = {"I like RPA","UNKNOWN FORMAT IB/K","PLEASE CHECK AGAIN","RETRY AFTER SOME TIME"}
Assign your notepad text to string for example strNotepadString, then split the lines in the notepad into array
hi @avejr748
thanks this working as expected; however, if Search String has no fix spaces, e.g. if it can be I like RPA or I like RPA then, it is not recognizing
Hi @Shruthika_r If that is the issue then a little modification would handle that
For each notepadstring
For each searchstring
If notepadstring.replace(" ","").tolower.contains(searchstring.replace(" ","").tolower) then
Throw business exception
Basically you just remove all spaces in notepadstring and searching so they should match regardless of how many spaces comes in between "I like RPA"