subsonic - parsing "*" - quantifier {x,y} following nothing
I'm using Subsonics Substage, and have just recieved this error? Any suggestions as to the cause?
subsonic pars开发者_如何学Going "*" - quantifier {x,y} following nothing
I've run into this issue using regular expressions in .Net, and the following helped me out:
http://bbrown.info/2007/01/02/parsing-quantifier-xy-following-nothing-considered-harmful.aspx
This is the code I had that was experiencing the issue is similar to:
public void foo(string path, string userSearchPattern)
{
const string kPattern = "*";
// Interestnigly, using "*" here works ok.
string[] dirs = Directory.GetDirectories(path, kPattern, SearchOption.AllDirectories);
foreach (string subDir in dirs)
{
// user search pattern is "*"
Match m = Regex.Match(subDir, userSearchPattern);
if (m.Success)
{
// do something fun here
}
}
}
I changed kPattern and the userSearchPattern passed in to the following and all seems well. I had not put much thought into the regular expression I was creating, but the first comment in the post linked above revealed the facepalm moment -- I needed to tell the regular expression object I wanted zero or more of something...
string userSearchPattern = ".*";
foo(somePath, userSearchPattern);
I do not use Substage, but perhaps you are creating a query with "*" and need to tell it zero or more of something.
精彩评论