Regex for anchor Tag
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Regex for anchor Tag




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Regex for anchor Tag  
meendar@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-30-07 06:27 PM

Hi,

anyone know the RE expression for finding the anchor tags in an html
page.


Data : xxxxxxxxxxxx<a href ="xxxx.com" ></a>

I just need <a href ="xxxx.com


Thanks,
Meendar





[ Post a follow-up to this message ]



    Re: Regex for anchor Tag  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-30-07 06:27 PM

In article
<4eadab70-70ed-4da7-9867-1839fa4d5c6e@l6g2000prm.googlegroups.com>,
meendar@gmail.com wrote:

> Hi,
>
> anyone know the RE expression for finding the anchor tags in an html
> page.
>
>
> Data : xxxxxxxxxxxx<a href ="xxxx.com" ></a>
>
> I just need <a href ="xxxx.com

You don't want the '"' at the end of the URL?  And what about the
closing '>'?

< *[aA] [^>]

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***





[ Post a follow-up to this message ]



    Re: Regex for anchor Tag  
meendar@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-01-08 06:36 AM

On Dec 30 2007, 10:50 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article
> <4eadab70-70ed-4da7-9867-1839fa4d5...@l6g2000prm.googlegroups.com>,
>
>  meen...@gmail.com wrote: 
> 
> 
> 
>
> You don't want the '"' at the end of the URL?  And what about the
> closing '>'?
>
> < *[aA] [^>]
>
> --
> Barry Margolin, bar...@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***

> < *[aA] [^>]

There is some possiblity to have any text after the href end ie..

<a href = "xxxx.com" title ="new"></a>

I am looking for only <a href = "xxxx.com





[ Post a follow-up to this message ]



    Re: Regex for anchor Tag  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-01-08 06:36 AM

In article
<7e658650-0442-492a-aae4-405e7721072c@t1g2000pra.googlegroups.com>,
meendar@gmail.com wrote:

> On Dec 30 2007, 10:50 pm, Barry Margolin <bar...@alum.mit.edu> wrote: 
> 
>
> There is some possiblity to have any text after the href end ie..
>
> <a href = "xxxx.com" title ="new"></a>
>
> I am looking for only <a href = "xxxx.com

< *a +href *= *"[^"]*

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***





[ Post a follow-up to this message ]



    Re: Regex for anchor Tag  
Scott Lurndal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-02-08 12:23 AM

meendar@gmail.com writes:
>On Dec 30 2007, 10:50 pm, Barry Margolin <bar...@alum.mit.edu> wrote: 
> 
>
>There is some possiblity to have any text after the href end ie..
>
><a href = "xxxx.com" title ="new"></a>
>
>I am looking for only <a href = "xxxx.com

Use an xsl stylesheet processed by xsltproc.

e.g. something like:
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transfor
m'>
<xsl:template match="//a">
&lt;a href="<xsl:value-of select="attribute::href"/>
</xsl:template>
</xsl:stylesheet>


Run this through xsltproc:

$ cat /tmp/a.html
<html>
<head>
</head>
<body>
<a href="test1" fred="joe">test</a>
<a href="test2" fred="billbob">frod</a>
</body>
</html>
$ cat /tmp/a.xsl
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transfor
m'>
<xsl:template match="//a">
&lt;a href="<xsl:value-of select="attribute::href"/>
</xsl:template>
</xsl:stylesheet>
$ cat /tmp/a.html | xsltproc /tmp/a.xsl -
<?xml version="1.0"?>





&lt;a href="test1

&lt;a href="test2







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:25 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register