Skip to content

How to extend regex to accept @ in image urls

I have a regex for validating image urls, however some of the images are using @ for example:

How can I extend this regex to accept also the @ character inside of the image link?

Current regex look like this




If it can only be part of the image name, you can add a forward slash followed by matching the allowed chars including the @ before the last dot before the extension.

You can use a character class for the single chars instead of a grouping structure to match one of the listed characters.

If you don’t need the capturing groups, you can omit them to get a match only.


Regex demo

9 People found this is helpful