Monday 30 May 2016

php - Get text and link from anchor tag by regex

I have some HTML and I need to get link and text from the anchor tag.



$pattern = '/href="(.*)".*>(.*)<\/a>/'



I didn't get exact link from above pattern but If I used the following pattern



$pattern = '/href="(.*?)".*>(.*)<\/a>/'


I get the desired result, But I didn't understand what question mark (?) does here and why I don't get result If I am not using the question mark (?).

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...