How to use regex in a Capybara finder?
You can check that an attribute starts with a certain value using ^=
:
find("img[src^='https://www.example.com/image']")
The article, The Skinny on CSS Attribute Selectors, describes the various checks (equals, starts with, ends with, etc.):
#Equals
find("img[src='https://www.example.com/image']")
#Contains somewhere
find("img[src*='https://www.example.com/image']")
#Begins with
find("img[src^='https://www.example.com/image']")
#Ends with
find("img[src$='https://www.example.com/image']")