Hi,
I have written a regular expression which is supposed to pull a
direction (forward or reverse) designation from a file name.
Unfortunately, the direction designation can either be the whole word
("Forward" or "Reverse") or just a single letter ("F" or "R") and the rest
of the name is not as consistent as I would like.. For example
"P1|1_G10_Forward_primer.ab1" or "K8_I1_A01_F.ab1".
At the time I am processing the file names, I have already stripped off
the extension.
I have written the Regular Expression
public static Regex DirectionFromFIleName = new
Regex("_(?<Direction>[Forward_|Reverse_|R$|F$])");
This looks for the underscore, followed by "Forward" or "Reverse" or an "F"
as the last character in the string or an "R" as the last character in the
string, or so I thought.
In fact,
when Designation = "P1|1_G10_Forward_primer"
RegexLibrary.DirectionFromFIleName.Match(Designati on).Groups["Direction"].Value
= "F"!
How can it pick up that F when it is not the last character? I assume it has
something to do with putting the $ inside the square brackets, but I can't
figure out exactly what it is.
I can figure out a bunch of different work arounds for this, but I would
like to understand what the regular expression is doing for the future.
Thanks!
Ethan