String manipulation for a part of sentence

I want to extract/check if key is within the directory of file.

For example I have list of directories as below:
\Users\Documents\C1PN-SA-17 TORONTO

What to find: C1PN-SA-1
Objective: To find the exact match of key and choose that file (\Users\Documents\C1PN-SA-1-INDIA)

What have I did was doing the .Contains but all directories will return True.

You can try to make the contains more strict by: "C1PN-SA-1-"

as an alternate we can also shift to regex ismatch
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum


Hope the following expression will help you.

arrInput.Where(Function(s) System.Text.RegularExpressions.Regex.IsMatch(System.IO.Path.GetFileName(s),"C1PN-SA-1\D")).ToArray()

Sample (2.8 KB)


this one is a bit strict, i want it to by dynamic to cater the others possible scenario

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