replaced text substring with regular expression in pin toggle