samedi 10 février 2018

PHP preg_match_all() pattern issue

Completely confused with this pattern... I have a huge string and I need to extract the string starting with word "profile":" (including quotes mark) and ending with .jpg. Any character could be in between. Since there could be more than 1 result, but I need the 1st one only, I use preg_match() function to get the first result. Here I also need to get the string starting with http and ending with .jpg I have ended up with the following code, which doesn't work :(

preg_match_all('"profile":".*?jpg', $mystring, $matches);
preg_match( 'h.*?jpg', $mystring[0][0], $result );

Your advises are really appreciated!

Aucun commentaire:

Enregistrer un commentaire