String matching with array item

Hello,

I need some help in a string-matching task.

I have one string in two different formats as follows:

String.Format(“{0} {1} {2} // {3} {4} ({5})”, str0, str1, str2, str3, str4, str5)

and

String.Format(“{0}{1}{2}{3}{4}_{5}”, str0, str1, str2, str3, str4, str5)
(there is an underscore between all the variables form {0} to {5} => screenshot below)


image


I got the first string in the input and I need to see if the second string matches. The second string will be as item in an array.

Thank you for your suggestions.

Hi @SONYC,

Your question is not clear. Can you provide the input and expected output from this.

Regards,
Arivu

Hi @SONYC,

Assign activity:
regexPattern = String.Format("{0}_[{1}_]*{2}_[{3}_]*{4}_[{5}_]*", str0, str1, str2, str3, str4, str5)

Is Match activity:
regexOutput = System.Text.RegularExpressions.Regex.IsMatch(strInput, regexPattern)

Thank you for your contribution.

To be more specific the string is a file name.
I have the input file name and after the process, the file will be stored in a specific folder. I need to get all the files from that folder to check the presence of the new file among the older files.

The string in input might have different characters within
In this case it is like: “word1 word2 word3 // word4 word5 (word6)

The string to be checked will always be like this: “word1_word2_word3_word4_word5
Word ar separated by “_” (underscore)

The only exception will be if the input string contains “-” (the dash character).
If the input string contains the dash character like: “word1 word2 - word3 word4 word5
The string in the output will be: “word1_word2_-_word3_word4_word5

In conclusion:

  • every space will be replaced by an underscore
  • every special character will be removed /()\ etc…