Hi Hon-Kie. $coeff = &random(1,5); $c_quest=($coeff == 1 ? '?' : ''); $c_re = qr/\Q$coeff\E$c_quest/; $var = qr/\Qx\E/; $re = '/^\s*$c_re\s*\*?\s*$var\s*$/'; should work. -- guy@albertelli.com 0-7-2-1-27,137