Regular Expression | Picking part of content between 2 markers

Asked

Viewed 246 times

-1

I have no knowledge of regular expression, so I do not know if it is possible to carry out the solution of my problem.

Throughout the HTML code of a site, it always has a code similar to this.

"placeholder":"https:\/\/ci.hdv6.com\/videos\/78\/13\/8787575\/thumbs_65\/(m=eaAaGwObaaaweyaY)(mh=c_sPzVwXUfENWpYI)6.jpg",

I’d like to do the following.

Grab all the content that starts at:

"placeholder":"

And ends in:

",

In case it would be:

https:\/\/ci.hdv6.com\/videos\/78\/13\/8787575\/thumbs_65\/(m=eaAaGwObaaaweyaY)(mh=c_sPzVwXUfENWpYI)6.jpg

NOTE: I’m using CURL to get all the HTML of a site, so I can find a Techo like this to get just this link.

And extremely important to get through the word PLACEHOLDER as an initial marker, as there are other similar links on the site.

  • I would like if possible, in PHP or Javascript languages

  • in php would be (?<="placeholder":").*(?=")

1 answer

0

let string = "placeholder:https:\/\/ci.hdv6.com\/videos\/78\/13\/8787575\/thumbs_65\/(m=eaAaGwObaaaweyaY)(mh=c_sPzVwXUfENWpYI)6.jpg"

let result = /https.+jpg$/.exec(string)[0]

console.log(result);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.