There are lots of examples on the forum showing how to use regex in scripts, including one you posted yourself recently.