Solved

Reg expression.

Posted on 2006-11-30
6
168 Views
Last Modified: 2010-04-16
I have a problem parsing this?

about:blankahm-050-en.html#AHM050-3

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 "";
                  }



0
Comment
Question by:mathieu_cupryk
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:CBeach1980
ID: 18048783
How exactly are you trying to parse it?
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 18049318
Hi mathieu_cupryk;

How do you want to parse this line?

    about:blankahm-050-en.html#AHM050-3

Fernando
0
 

Author Comment

by:mathieu_cupryk
ID: 18050360
about:blank I want to get rid of #AHM050-3
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 18051151
Hi mathieu_cupryk;

The following code sample will do what you want.

using System.Text.RegularExpressions;

            string input = "about:blankahm-050-en.html#AHM050-3";

            input = Regex.Replace(input, "(about:blank[^#]*).*",
                "$1", RegexOptions.IgnoreCase);

            // The message will display about:blankahm-050-en.html
            MessageBox.Show(input);

Fernando
0
 

Author Comment

by:mathieu_cupryk
ID: 18053489
Is there a way to differ. between ie6 strings and ie7
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 18054123
I do not know how to differ between IE6 and IE7. I myself do not do web development.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now