Solved

Reg expression.

Posted on 2006-11-30
6
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

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

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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 63

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 63

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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