ok thanks,a simple answer but I'd like to understand the implications of using or not using the $&. From my untrained eye it seems that answer you kindly posted will be scanning the string twice. Once for the general pattern search and then again for the specific pattern, whereas using $& would not involve the second string scan ?