replaced replace substr with regex