0

I have been using this method : console.log($(data).find('._2s25 ._606w')); to grab a portion of the data which I have already mentioned in my this question, but now it is returning undefined, can anyone help. I am trying to get the URL of that specific href attribute of element a of class ._2s25 ._606w. if it is possible with regex then please let me know, because the data returned will be the html but that html will be a string.

Nadeem
  • 145
  • 1
  • 13
  • Yes, it's possible with a regex. Provide us with a **complete** example input and the expected output. – Marc Lambrichs Sep 16 '17 at 05:31
  • [This](https://docs.google.com/document/d/1Bm35kfAmc-BoLjAdjAA-rtdc3seTapUMGbKUl_-0_4o/edit?usp=sharing) is the response I get . and I want to grab that specific href, with that class name. @MarcLambrichs – Nadeem Sep 16 '17 at 05:46

1 Answers1

1

You may try this regex:

<a.*?class="[^"]*_2s25 ._606w[^"]*".*?href="([^"]+)".*?<\/a>

Regex Demo

You can try the following:

const regex = /<a.*?class="[^"]*_2s25 ._606w[^"]*".*?href="([^"]+)".*?<\/a>/g;
const str = `<a class=""asdfasdfsadf

<a class="_2s25 ._606w"bla bla bla bla bla bla sdafjkasdfa href="https://www.facebook.com/AnteSoftTech" bla bla bla title="bla bla" ......................<img>bla</img>.<span></span>..................................</a>`;
let m;

if ((m = regex.exec(str)) !== null) {
console.log(m[1]);
    
}
Mustofa Rizwan
  • 10,215
  • 2
  • 28
  • 43