while() { #put a while around the regexes if there is multiple #regexes per line; aslo add a /g ( (/(regex1)/i && doSomethingForRegex1($1)) || (/(regex2)/i && doSomethingForRegex2($1)) || (/(regex3)/i && doSomethingForRegex3($1)) ) && still_do_a_general_func_if_needed($1); }