I am attempting to create a rule that will match any string apart from
those that are keywords in my language.
I have developed the following regular expression, which acheives this,
but, when trying to access a word that is accepted by the regular
expression, via $item[1], nothing is returned ( I have also tried
$item[0], $item[2] etc). I have placed a print statement in as a debugging
aid, to prove that the rule works properly debugging aid:
When entering a keyword, such as "return", as expected, nothing is
printed. However, when entering a non-keyword, such as "foo"
only the string "pattern matched OK" is printed, and the value of the
matched word ($item[1]) is not printed.
Can anyone tell me where I am going wrong here?
Followin is the offending piece of code
Paul Kennerley
ident : /^(?!(return|exit|if))[A-Za-z0-9_]*/
{
print "pattern matched OK\n";
print $item[1];
}