I have this pattern
.*;\/wp-content\/uploads\/(.*)\.
and this in string format
<div data-images="{"omniture":{"type":"","hasImpression":false},"slides":[{"title":"","omniture":null,"description":"","path":"/wp-content/uploads/auto-shows/frankfurt/2017/2019-porsche-cayenne/02-2019-porsche-cayenne-turbo-NP.jpg","thumbnail":"/wp-content/uploads/auto-shows/frankfurt/2017/2019-porsche-cayenne/02-2019-porsche-cayenne-turbo-NP.jpg?w=320&h=240&crop=1"},{"title":"","omniture":null,"description":"","path":"/wp-content/uploads/make/porsche/cayenne/2019/oem/21-2019-porsche-cayenne.jpg","thumbnail":"/wp-content/uploads/make/porsche/cayenne/2019/oem/21-2019-porsche-cayenne.jpg?w=320&h=240&crop=1"},{"title":"","omniture":null,"description":"","path":"/wp-content/uploads/make/porsche/cayenne/2019/oem/23-2019-porsche-cayenne.jpg","thumbnail":"/wp-content/uploads/make/porsche/cayenne/2019/oem/23-2019-porsche-cayenne.jpg?w=320&h=240&crop=1"},{"title":"","omniture":null,"description":"","path":"/wp-content/uploads/make/porsche/cayenne/2019/oem/30-2019-porsche-cayenne.jpg","thumbnail":"/wp-content/uploads/make/porsche/cayenne/2019/oem/30-2019-porsche-cayenne.jpg?w=320&h=240&crop=1"}]}"></div>
I want to match all the occurrences that appear between ;/wp-content/uploads/
and .jpg
I tried to match this, but it shows last group only.
I am new to regex, so please correct me with the implementation here, thank you.
CodePudding user response:
You can make use of lookarounds to do clean extractions:
(?<=;\/wp-content\/uploads\/)(.*?)(?=\.jpg)