regexp question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wim Roffal

    #1

    regexp question

    I have a regalar expression to extract an html link from a page:

    href=([\"']?)([^>\\1]*\.html)\\1(?: [^>]*)?>

    It looks after the "href" for an optional quote and then looks for something
    that is not the quote or the endarrow.

    The problematic part is [^>\\1]*. It should exclude anything with the quote,
    but somehow that doesn't work. Maybe \\1 is not allowed inside brackets?
    I would like some advice on how to handle this.

    Thanks,
    Wim


  • John Dunlop

    #2
    Re: regexp question

    Wim Roffal wrote:
    [color=blue]
    > I have a regalar expression to extract an html link from a page:[/color]

    Use an HTML parser.
    [color=blue]
    > href=([\"']?)([^>\\1]*\.html)\\1(?: [^>]*)?>
    >
    > It looks after the "href" for an optional quote and then looks for something
    > that is not the quote or the endarrow.
    >
    > The problematic part is [^>\\1]*. It should exclude anything with the quote,
    > but somehow that doesn't work. Maybe \\1 is not allowed inside brackets?[/color]

    Back references aren't recognised in character classes.

    [ ... ]

    HAGW!

    --
    Jock

    Comment

    Working...