IIS ASP - Can you help with this Regular Expression?

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > May 2004 > Can you help with this Regular Expression?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Can you help with this Regular Expression?
Danny

2004-05-30, 11:53 am

Hello

here is a pattern I am using in regexp module:
href(.*?)[\x22>][^\x22]*\x22

This string seems to work in that it will return
href = "http://www.domain.com"

from href tags such as this.
<a href = "http://www.domain.com">This is a link</a>

it handles the spaces that may exist before and after equal sign.
(basically I am trying to extract links out of my url)

is there a way I can take this pattern a bit further to return just the
http://www.domain.com

I am new to regexp but have managed to get this far.

Thanks in advance

Danny


Chris Hohmann

2004-05-30, 11:53 am

"Danny" <dannywork5@hotmail.com> wrote in message
news:sl0tc.53662$cz5.19972989@news4.srv.hcvlny.cv.net...
> Hello
>
> here is a pattern I am using in regexp module:
> href(.*?)[\x22>][^\x22]*\x22
>
> This string seems to work in that it will return
> href = "http://www.domain.com"
>
> from href tags such as this.
> <a href = "http://www.domain.com">This is a link</a>
>
> it handles the spaces that may exist before and after equal sign.
> (basically I am trying to extract links out of my url)
>
> is there a way I can take this pattern a bit further to return just the
> http://www.domain.com
>
> I am new to regexp but have managed to get this far.
>
> Thanks in advance
>
> Danny
>
>

Wrap the part you want in parenthesis and reference the submatches
collection

href(.*?)[\x22>]([^\x22]*)\x22

In this case it's the second submatch your interested in. Here's the
documentation for the submatches collection which includes a code example.
http://msdn.microsoft.com/library/e...lSubMatches.asp


Danny

2004-05-30, 11:53 am

That is great, and it worked for me.

Thanks very much


"Chris Hohmann" <nospam@thankyou.com> wrote in message
news:uW6ioD1QEHA.3748@TK2MSFTNGP09.phx.gbl...
> "Danny" <dannywork5@hotmail.com> wrote in message
> news:sl0tc.53662$cz5.19972989@news4.srv.hcvlny.cv.net...
> Wrap the part you want in parenthesis and reference the submatches
> collection
>
> href(.*?)[\x22>]([^\x22]*)\x22
>
> In this case it's the second submatch your interested in. Here's the
> documentation for the submatches collection which includes a code example.
> http://msdn.microsoft.com/library/e...lSubMatches.asp
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com