in reply to Generalising string in pattern

Your question is very unspecific, assuming you want to match this string format given varaible is called $pattern in which case you should look at the \d character class in perlre and perhaps consider using qr() if this regex is to be used repeatedly