user3266989
user3266989

Reputation: 25

How to pull out a substring out of the url?

I need to pull out C5044SGXAU out of the following url:

    <div class="zg_itemImageImmersion"><a href="http://www.website.com/Doggy-PIC-14-Pitbull-Induction-1500-Matt/dp/C5044SGXAU/ref=zg_bs_3741261_1"><img src="http://dog.images-website.com/images/I/41dXgzYztML._SL160_SL150_.jpg" alt="Doggy PIC-14 Pitbull Induction Cookt..." title="Doggy PIC-14 Pitbull Induction Cookt..." onload="if (typeof uet == 'function') { uet('af'); }"></a></div>

I'm trying to get this as a result:

C5044SGXAU

How to do that?

Upvotes: 1

Views: 77

Answers (1)

Venky
Venky

Reputation: 93

Use the following regex

http:\/\/[^\/]+\/[^\/]+\/[^\/]+\/([^\/]+)\/[^\/]+

Demo

Upvotes: 1

Related Questions