ihorko
ihorko

Reputation: 6945

Regular Expression to parse out anchor tag's href

I have html code:

<a href="javascript:void(0);" id="seller0-showAllImage" onclick="showPlusBox(0,'/products/plusbox?cid=9286328115358229395&amp;authorid=2860562')" class="fl">

in result I need to have only string:

/products/plusbox?cid=9286328115358229395&amp;authorid=2860562

How can I match it in RegEx from the html code? Thanks!

Upvotes: 1

Views: 123

Answers (2)

Joey
Joey

Reputation: 354406

Match:

showPlusBox(0,'([^']+)')

Reference $1 is then the string you're looking for.

Of course, this depends pretty much on the exact strings you want to match; where it's embedded, etc. With a single example there isn't much to extrapolate. Honestly, the Regex

/products/plusbox\?cid=9286328115358229395&amp;authorid=2860562

would also match what you're looking for, for example.

Upvotes: 3

sidyll
sidyll

Reputation: 59277

This regex:

/products/plusbox\?cid=9286328115358229395&authorid=2860562

Matches it.

If you want a more generic expression, please provide more info.

Upvotes: 2

Related Questions