Update regex pattern and mark matching position