开发者

What is the problem with this regular expression?

I have the following code:

Regex scale = new Re开发者_Python百科gex(@"/^(\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.


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)?)$"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜