With the following regex, it is not matching -lp[number]
public static Regex lPageID = new Regex(@"\-lp\d+\.", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public static int GetPageIDFromPath(string path)
{
return GetIDFromPath(lPageID, path);
}
example path that is sent to my function:
/domain/Some-Landing-Page-Meta-Title-lp1.lp
private static int GetIDFromPath(Regex regex, string path)
{
Match match = regex.Match(path);
if (match.Success)
{
string value = match.Value;
value = value.Substring(2, value.Length - 3);
int id;
if (Int32.TryParse(value, out id))
return id;
}
return 0;
}
I need to grab the number after -lp. IT seems to be that it doesn't like the extra character or doesn't like p because -l works fine if I change the regex to a single letter after the - such as:
public static Regex lPageID = new Regex(@"\-l\d+\.", RegexOptions.Compiled | RegexOptions.IgnoreCase);
with example string of: /domain/Some-Landing-Page-Meta-Title-l1.l