Perl regex word matching -


how match following strings using perl regexp ?

$line="virtual void function"; $line="virtual function"; $line="void function"; $line="function"; $line="pure virtual function"; $line="extern function"; $line="extern void function"; 

i.e match 0 or n number of function qualifiers separated atleast 1 space followed string "function".

it shouldn't match

$line="// function"; $line="asdfgh";      $line="endfunction";      

is there similar

$line=~/^([evp\s]*) function/ ; 

which can used words instead of characters ?

(?:pat1|pat2) patterns [ab] chars.

/^(?:(?:extern|pure|virtual|void)\s+)*function/ 

Comments