Posted: Mon Oct 23, 2006 2:47 pm Post subject: nested greps
I have 120 Korean students progamming chatbots as the project phase of their conversation class ... I'm using RiveScript and some CGI ... I wrote a script that student by student ... summarizes their rscript files ... it just opens each file and reads the contents into an array ...
I'm using grep's to tally rscript features ... everything works ... I'm just wondering if there is a better way to write this one regex ... it's to count the number of atomic triggers and the only regex I can get to work looks like this ...
Code:
grep(!/\*+/, grep(/^\s*\+{1}/, @file))
Is there a better way to count the number of elements that start with 'x' and do not contain 'y' ...
thanks ... I didn't realize grep took arguements similar to a map block ... your trick has tidied up quite a few of the uglier regex's I've got laying about ...