Solved

Reg expression.

Posted on 2006-11-30
6
169 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 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

803 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