Solved

Reg expression.

Posted on 2006-11-30
6
171 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
Technology Partners: 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!

 
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Can I command line build a C# application? 6 52
asp web application 3 37
.NET Enums [Flags] & Bitwise Design Question 6 39
orderby list (from Json) 1 28
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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

735 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