Regular Expressions

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

    #1

    Regular Expressions

    Hi

    I have a regex..... (@"href\s*\=\ s*[^\s+^>]+") which pulls out all the text
    from a document starting with href
    and ending in any white space or a ">" character.

    What I would like to do is also remove the "href=" from the start of all the
    matches I get, am I going to have to
    run a replace on the matches or is there a way of doing it through the
    pattern itself.

    TIA

    Chris


  • Jochen Kalmbach

    #2
    Re: Regular Expressions

    Chris wrote:
    [color=blue]
    > Hi
    >
    > I have a regex..... (@"href\s*\=\ s*[^\s+^>]+") which pulls out all the
    > text from a document starting with href
    > and ending in any white space or a ">" character.
    >
    > What I would like to do is also remove the "href=" from the start of
    > all the matches I get, am I going to have to
    > run a replace on the matches or is there a way of doing it through the
    > pattern itself.[/color]

    Use @"href\s*\=\s*( \S[.+^>])>"
    and use the 2nd Match


    --
    Greetings
    Jochen

    Do you need a memory-leak finder ?

    Comment

    • Chris

      #3
      Re: Regular Expressions

      Thanks for your response Jochen

      But I get no matches at all using that pattern, quite new to regex so I may
      be doing it wrong. I'm using Expresso to test which I found referenced in
      an earlier post.

      thanks

      Chris.

      "Jochen Kalmbach" <nospam-Jochen.Kalmbach @holzma.de> wrote in message
      news:Xns94417F7 5C605BJochenKal mbachholzm@127. 0.0.1...[color=blue]
      > Chris wrote:
      >[color=green]
      > > Hi
      > >
      > > I have a regex..... (@"href\s*\=\ s*[^\s+^>]+") which pulls out all the
      > > text from a document starting with href
      > > and ending in any white space or a ">" character.
      > >
      > > What I would like to do is also remove the "href=" from the start of
      > > all the matches I get, am I going to have to
      > > run a replace on the matches or is there a way of doing it through the
      > > pattern itself.[/color]
      >
      > Use @"href\s*\=\s*( \S[.+^>])>"
      > and use the 2nd Match
      >
      >
      > --
      > Greetings
      > Jochen
      >
      > Do you need a memory-leak finder ?
      > http://www.codeproject.com/tools/leakfinder.asp[/color]


      Comment

      • Jochen Kalmbach

        #4
        Re: Regular Expressions

        Jochen Kalmbach wrote:
        [color=blue]
        > Chris wrote:
        >[color=green]
        >> Hi
        >>
        >> I have a regex..... (@"href\s*\=\ s*[^\s+^>]+") which pulls out all
        >> the text from a document starting with href
        >> and ending in any white space or a ">" character.
        >>
        >> What I would like to do is also remove the "href=" from the start of
        >> all the matches I get, am I going to have to
        >> run a replace on the matches or is there a way of doing it through
        >> the pattern itself.[/color]
        >
        > Use @"href\s*\=\s*( \S[.+^>])>"[/color]

        Now corrected:
        @"href\s*\=\ s*([^\s^>]*)>"



        --
        Greetings
        Jochen

        Do you need a memory-leak finder ?

        Comment

        Working...