Improved regular expressions to handle cases with :#:# in the code