Re: .NET Regex href

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Robby (edmund_at_not.my.email.com)
Date: 12/13/04


Date: Tue, 14 Dec 2004 10:18:15 +1300


You could add a grouping that has both the " and the ' like the following;

href\s*=\s*(?:["'](?<1>[^"']*)["']|(?<1>\\S+))

You need to add your escapes for C# strings. I am VB. :)

Robby

"Ryan Moore" <ryan@rymoore.com> wrote in message
news:e910aEV4EHA.604@TK2MSFTNGP10.phx.gbl...
>I am trying to write a regex expression which extracts all href links
> from a HTML page... I'm currently using the following:
>
> href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))
>
> but it has a problem with hrefs enclosed in single quotes, such as:
>
> <a href='anotherpage.htm'>
>
> I'm not a regex guru, can anyone point me in the right direction?
>
> Thanks!
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Re: Forth 200x, S\q
    ... new escapes with upper-case letters for existing escapes, ... Case-sensitivity systems are a pain? ... Case-insensitivity in literal strings, ... Case-insensitivity in file systems, ...
    (comp.lang.forth)
  • Re: Escaping characters
    ... there is a distinction between strings that are between ... double quotes and strings in single quotes. ... "\\" escapes the necessary characters, ... I know the backslash escapes a character, so in the first line, I ...
    (comp.lang.ruby)
  • Re: [PHP] extract escaped quoted strings
    ... though no processing of the actual escapes is required nor desirable. ... for instance are you looking to pull these strings from PHP ... Application and Templating Framework for PHP ...
    (php.general)
  • Re: Forth 200x, S\q
    ... new escapes with upper-case letters for existing escapes, ... Inc. will phase out the usage of upper-case escapes over time. ... to use uppercase for escapes makes them standout in a string. ...
    (comp.lang.forth)