Ext Javascript Library for beginners

The Ext Javascript for beginners, as I learn ExtJS & Javascript so will you!

Matching Backlinks and Anchor Text with a Regular Expression

Posted on | October 6, 2008 |

Hi Guys,

If anyone reads this, well done you. You’re about to become witness to my first ever published regular expression, so go easy on the critique!

I needed this to show what pages were linking into other pages (backlinks) and what was the associated anchor text used by the link. I spent a morning or so playing around with the following regular expression to try and match all backlinks to a specific URL and its anchor text.


<a [^/>]*href=["\'](your-url-here).*["\'][^/>]*/?>(.*)

This does the job very nicely, I’m sure it could be speeded up slightly to avoid being overtly greedy. But for now I’m happy with it.

Notes

  1. You must quote the URL you use. There is a way in ExtJS to do this and PHP.
  2. Ext.escapeRe() and preg_quote() in PHP should get the job done!

Comments

One Response to “Matching Backlinks and Anchor Text with a Regular Expression”

  1. Lulli
    October 29th, 2008 @ 8:44 am

    Good for people to know.

Leave a Reply





Ext Javascript Library for beginners uses Thank Me Later

  • My Tweets

    Follow Me on Twitter
  • Tags

  •  

    January 2009
    M T W T F S S
    « Dec    
     1234
    567891011
    12131415161718
    19202122232425
    262728293031