Link to home
Start Free TrialLog in
Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada

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].ToString();
                        else
                        {
                              //MessageBox.Show(NewMatch[NewMatch.Count - 2].Groups[1].Captures[0].ToString());
                              return (NewMatch[NewMatch.Count - 2].Groups[1].Captures[0].ToString() +
                                    NewMatch[NewMatch.Count - 1].Groups[1].Captures[0].ToString());
                      }
                  }
                  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].Captures[0].ToString();
                        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/Logo_AirCandaACGHS-www.jpg"><br>
<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
Avatar of CBeach1980
CBeach1980

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial