If you want to group some items in a regular expression, but don't want to have save it for later use, put a ?: after the (
eg:
source text: test1.gif test2.png test3.jpg
To match a filename with only gif and png extensions:
/(.*?\.(?:gif|png))/
this wil match : test1.gif, test2.png
without the ?: this would match: test1.gif, gif, test2.png, png