Regular Expressions

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

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
 
Chris said:
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.

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
 
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 said:
Chris said:
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.

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
 
Jochen said:
Chris said:
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.

Use @"href\s*\=\s*(\S[.+^>])>"

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



--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
 
Back
Top