RakhiKalra
Programmer
Hi,
I am building a facility to search site contents utility which searches the specified text on the other pages of the same site and gives the list of all pages where it has found the search text.
the search is being done properly.but there is one case in which i am getting an error, when i am entering "*" (an asterisk) in the search text box.error is the following:-
System.ArgumentException: parsing "*" - Quantifier {x,y} following nothing. Parameter name: *
the code comes here
public void SearchWords(string SearchWords)
{
int intCounter,intLocation;
string[] strSearchWords;
MatchCollection mcMatchCollection;
string strLeft,strContents;
try
{
strSearchWords = SearchWords.Split(' ');
for(intCounter=0;intCounter<strSearchWords.Length;intCounter++)
{
//error comes on the following statement
mcMatchCollection = Regex.Matches(Contents,strSearchWords[intCounter],RegexOptions.IgnorePatternWhitespace);
if(mcMatchCollection.Count>0)
{
MatchCount=mcMatchCollection.Count;
strLeft=Contents.Substring(0,mcMatchCollection[0].Index);
intLocation=strLeft.LastIndexOf(".");
if(intLocation==-1)
intLocation=0;
else
intLocation++;
strContents=Contents.Substring(intLocation,Contents.Length-intLocation);
if(strContents.Length>500)
Description=strContents.Substring(0,500);
else
Description=strContents;
}
}
}
catch(Exception objException)
{
throw new Exception(objException.Message,objException);
}
}
#endregion
Rakhi
I am building a facility to search site contents utility which searches the specified text on the other pages of the same site and gives the list of all pages where it has found the search text.
the search is being done properly.but there is one case in which i am getting an error, when i am entering "*" (an asterisk) in the search text box.error is the following:-
System.ArgumentException: parsing "*" - Quantifier {x,y} following nothing. Parameter name: *
the code comes here
public void SearchWords(string SearchWords)
{
int intCounter,intLocation;
string[] strSearchWords;
MatchCollection mcMatchCollection;
string strLeft,strContents;
try
{
strSearchWords = SearchWords.Split(' ');
for(intCounter=0;intCounter<strSearchWords.Length;intCounter++)
{
//error comes on the following statement
mcMatchCollection = Regex.Matches(Contents,strSearchWords[intCounter],RegexOptions.IgnorePatternWhitespace);
if(mcMatchCollection.Count>0)
{
MatchCount=mcMatchCollection.Count;
strLeft=Contents.Substring(0,mcMatchCollection[0].Index);
intLocation=strLeft.LastIndexOf(".");
if(intLocation==-1)
intLocation=0;
else
intLocation++;
strContents=Contents.Substring(intLocation,Contents.Length-intLocation);
if(strContents.Length>500)
Description=strContents.Substring(0,500);
else
Description=strContents;
}
}
}
catch(Exception objException)
{
throw new Exception(objException.Message,objException);
}
}
#endregion
Rakhi