Refine the substitute() to match * at ^ and $ of pattern