PHP Regex
Source:
http://example.com/wp-content/uploads/2017/01/image.jpg
https://example.com/wp-content/uploads/2017/01/image2.jpg
http://example.com/wp-content/plugins/example-plugin/images/image.jpg
Objective
I want to match all strings that:
- Contains HTTP, but not HTTPS
- Contains
wp-content/uploads/
.. and I do not want to capture the wp-content/uploads/ part so that's a non-capturing group from what I can figure.
I have tried doing a positive-lookahead but I can't seem to get it right. This is what I've come up with so far but I dont' know where to put the HTTP part. The regex tester at regex101 just doesnt match.
(?=(?:(wp-content\/uploads)+))
Update:
To clarify, I need simple regex, no PHP code. In other words, PCRE which PHP uses.
if (parse_url($url, PHP_URL_SCHEME) == "https") { return false; }not suitable for you?~^http://[^\v]+/wp-content/uploads[^\v]+$~mgit needs to be multiline (m) and global (g): regex101.com/r/hId37t/1http://[^\s'"]+?wp-content/uploads/[^\s"']+