Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Regular expression

Posted on 2006-11-30
1
Medium Priority
?
184 Views
Last Modified: 2011-09-20
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.
0
Comment
Question by:mathieu_cupryk
1 Comment
 
LVL 4

Accepted Solution

by:
CBeach1980 earned 2000 total points
ID: 18048315
(Str2LookIn.IndexOf(@"http://") == -1) will only execute if "http://" is not in Str2LookIn.  To get it to execute when it is there you need (Str2LookIn.IndexOf(@"http://") != -1)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question