Regular Expressions 101

Get the name of the image

1

Regular Expression
PCRE (PHP <7.3)

/
(?!.*?\/)(?P<image>.*?)(?:\.(?:jpg|png))
/
g

Description

This regex will be getting the name of the image

source: data/products/cocacola/logo_new_version.jpg match: logo_new_version

It will be returned logo_new_version on image index

Submitted by strubloid - 7 years ago