I have a simple outcome to detect part of a file name. My files have their general name (FILENAME), a second name (SECONDNAME#) and a final tag, all links by underscores.
I am after the second name, which can have a small number of values. The third part, the final tag, can be highly variable and is not checked for.
FILENAME_SECONDNAME1_DS.txt
FILENAME_SECONDNAME2_DS.txt
FILENAME_SECONDNAME3_ER.txt
Detecting the trailing underscore after teh second name is important to help indicate I have the second name and are not accidentally detecting a similar string part in the filename.
I check with the following
set RE = new RegExp
RE.Ignorecase = true
sCONST = "FILENAME_SECONDNAME1_DS.txt"
RE.pattern = "(SECONDNAME1)|(SECONDNAME2)|(SECONDNAME3)_"
if RE.test(sCONST) = true then
set matches = RE.Execute(sCONST)
for each match in matches
MsgBox match.Value
next
end if
VB's RegExp matches my pattern but match.Value never has the underscore. I can only assume I am not matching the underscore with my pattern. How can I get the underscore included in my matches?