I have list of words that i want to find from string…if any words found then it should return matched words.
LIST of words we need to search:
Example INPUT string:
“CURENT ACCOUNT DETAILS IS 456899 IF FOUND THEN RETURN COMPANY NAME”
EXAMPLE 2 INPUT STRING:
“CURRENT ACCOUNT NO 567890 IS NOT VALID”
Note: it should not match COUNT NO From ACCOUNT NO .
Example 3 input string:
" RTN NO 6788 FOR ACCOUNT DETAILS XYZ COUNT NO IS 7 KYC DETAILS KKK"
Ex: you stored your string in str_text variable using assign activity like:
str_text=" RTN NO 6788 FOR ACCOUNT DETAILS XYZ COUNT NO IS 7 KYC DETAILS KKK"
then Use If activity with message like:
str_text.contain(“RTN NO”) and put use Log message in Then section with message “RTN NO”
do same for others also like:
str_text.contain(“COMPANY NAME”) and put use Log message in Then section with message “COMPANY NAME”
str_text.contain(“COUNT NO”) and put use Log message in Then section with message “COUNT NO”
str_text.contain(“COMPANY DETAILS”) and put use Log message in Then section with message “COMPANY DETAILS”
output you will get as expected.
let me know, If any question…
or ping me on my mail id:
Hope the below steps would help you resolve this
Say you have the string in a variable named Strinput
Then use the below assign activity like this
matches_output = System.Text.RegularExpressions.Regex.Matches(Strinput.ToString, “(COMPANY NAME|RTN NO|COUNT NO|COMPANY DETAILS)”)
Where matches_output is a variable of type list of Match objects (
You can get the value by iterating them in FOR EACH activity
For that in for each activity change the type argument property as System.Text.RegularExpressions.Match
—then inside the loop use a assign activity and mention like this
str_output = item.ToString
Listed words are repeating and can be multiple which is not fixed.
In future it can be 90-100 words, till now we have 60 words.
And Kindly check Note as well,
For example in 2nd input:
It should not consider COUNT NO from word ACCOUNT NO.
i.e. AC"COUNT NO"
Yeah it would find only the word mentioned in exact
Say Account means Account
To avoid partial matches, you can add “\b” to the regex pattern:
\b(COMPANY NAME|RTN NO|COUNT NO|COMPANY DETAILS)\b
If your list of key words are dynamic, you can use String.Join() to create the pattern instead:
pattern = "\b(" + String.Join("|", listOfWords) + ")\b"
matches_output = System.Text.RegularExpressions.Regex.Matches(strInput, pattern)