I have text like this 1960PDDO001c date.jpg
I only want to select this part 1960PDDO001
this part c date.jpg
is not needed. I have been writing regex expression selecting only specific part on url since it is this last part is dynamic it changes from image to image i wasn't able to write a good regex. This is the full url http://varietyvista.com/01b LC Doubled Dies Vol 2/1960 Photos/1960PDDO001c date.jpg
CodePudding user response:
This regex will capture the eleven alphanumerical characters that follow "Photos/", regardless of what comes after them.
Photos\/(\w{11})
Photos
means: the literal "Photos" string.\/
means: a literal/
.\w
matches any alphanumerical character or underscore (it's equivalent to[a-zA-Z0-9_]
).{11}
specifies that the previous token needs to be present 11 times.(...)
capture a group.