I am trying to find a regex that will be able to treat 3 cases that i have in html.
For instance,
- background-image: url(https://www.aaa.com/xxx/picture.png); background-size: 100%...
- background-image: url("https://www.aaa.com/xxx/picture(1_2)_pic(23).png")
- background-image: url(https://www.aaa.com/xxx/picture)
In this 3 cases , i want to extract the 3 urls:
- https://www.aaa.com/xxx/picture.png
- https://www.aaa.com/xxx/picture(1_2)_pic(23).png
- https://www.aaa.com/xxx/picture
I created a regex that is able to extract only the first two. Unfortunately, cannot think of the regex that will be able to get the third case(url path without extension) also inside that one regex.
what i came up with so far:
/background(?:-image|):[\s]*url[(][\"']?(https?:\/\/[^’\”]+[.](?:gif|png))[‘\”]?/g
Appreciate all the help.