Reputation: 9917
I have the following code:
Regex scale = new Regex(@"/^(\d+)x(\d+)-([a-zA-Z0-9]+(\.jpg)?)$/");
Match m = scale.Match(alias);
if (m.Success)
{
//do something
}
alias contains, 10x10-uu.jpg
and is not matching - success is always false.
What am I doing wrong? :-) Thanks.
Upvotes: 1
Views: 100
Reputation: 723568
Delimiters are not necessary in .NET regexes, these are only found in PCRE and JavaScript regexes. Your forward slashes are being treated literally, meaning you get /^
and $/
, which make no sense.
@"^(\d+)x(\d+)-([a-zA-Z0-9]+(\.jpg)?)$"
Upvotes: 10