Solved

Reg expression.

Posted on 2006-11-30
6
170 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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