mathieu_cupryk
asked on
Regular expression
I have the following:
MatchCollection NewMatch = Regex.Matches(Str2LookIn, @"[/*\\*]([\(\)\#a-z0-9\._ -]*)", RegexOptions.IgnoreCase);
if (NewMatch.Count > 0)
{
if (Str2LookIn.IndexOf(@"http://") == -1)
return NewMatch[NewMatch.Count - 1].Groups[0].Captures[0].T oString();
else
{
//MessageBox.Show(NewMatch [NewMatch. Count - 2].Groups[1].Captures[0].T oString()) ;
return (NewMatch[NewMatch.Count - 2].Groups[1].Captures[0].T oString() +
NewMatch[NewMatch.Count - 1].Groups[1].Captures[0].T oString()) ;
}
}
else
{
NewMatch = Regex.Matches(Str2LookIn, @"^(about:(blank)?)?([\(\) _\-\.a-z0- 9]*\.+[a-z ]{4})(\#+( [_\-\.a-z0 -9]*))?", RegexOptions.IgnoreCase);
if (NewMatch.Count != 0)
return NewMatch[0].Groups[3].Capt ures[0].To String();
else
return "";
}
I need if (Str2LookIn.IndexOf(@"http://") == -1)
to execute if the string is http://www.aircanada.com
<table class="CompanyInfo">
<tr>
<td align="center">
<p><a href="http://www.aircanada.com" target="_blank"><img src="../../images/Home/Log o_AirCanda ACGHS-www.jpg"><b r>
<span class="CompanyName">Air Canada ACGHS</span><br>http://www.aircanada.com</a></p>
</td>
</tr>
</table>
Something is wrong with that line of code can someone help me out.
MatchCollection NewMatch = Regex.Matches(Str2LookIn, @"[/*\\*]([\(\)\#a-z0-9\._
if (NewMatch.Count > 0)
{
if (Str2LookIn.IndexOf(@"http://") == -1)
return NewMatch[NewMatch.Count - 1].Groups[0].Captures[0].T
else
{
//MessageBox.Show(NewMatch
return (NewMatch[NewMatch.Count - 2].Groups[1].Captures[0].T
NewMatch[NewMatch.Count - 1].Groups[1].Captures[0].T
}
}
else
{
NewMatch = Regex.Matches(Str2LookIn, @"^(about:(blank)?)?([\(\)
if (NewMatch.Count != 0)
return NewMatch[0].Groups[3].Capt
else
return "";
}
I need if (Str2LookIn.IndexOf(@"http://") == -1)
to execute if the string is http://www.aircanada.com
<table class="CompanyInfo">
<tr>
<td align="center">
<p><a href="http://www.aircanada.com" target="_blank"><img src="../../images/Home/Log
<span class="CompanyName">Air Canada ACGHS</span><br>http://www.aircanada.com</a></p>
</td>
</tr>
</table>
Something is wrong with that line of code can someone help me out.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.