How can I expand this regex match to the left http(s) to match the entire URL? – Stack Overflow

I’m using the regex \/s1600-h\/[^\/\s'"]+ to match URLs with the directory of /s1600-h/ in an URL, i.e.

http://localhost/wpcomics/wp-content/images/_Tkt_A2r1p6I/RlcBEI/AAAAEU/D630/s1600-h/tedsobject.jpg

and that matches from /s1600-h/ to the right and includes the file and extension.

enter image description here

But how can I expand the match to the left to match the entire URL? No matter the number of subdirectories? And either http or https?

Here’s a fiddle: regex101.com/r/agB4iJ/1

Read more here: Source link