[Cook] Cook Patterns / Regular Expressions Question

Matthew Lee mlee at klaxoniqa.com
Thu Oct 3 14:37:29 EST 2002


I'm having a couple of problems with cook patterns and regular
expressions.

I want to determine if a substring appears within a list of words, and
print out those words in which the substring is found.

Here is a debugging attempt at getting this to work:

function print match [match_mask %1g++%2
		      avr-g++ g++ h8300-coff-g++ g++-foo foo-g++-bar];


The result is:

cook: match avr-g++ h8300-coff-g++ foo-g++-bar


The result is missing g++ and g++-foo.  I understand why, because %1
cannot match a leading empty string.  Unfortunately, I cannot use
%0g++%2 as the mask, because %0 must be either empty or have a trailing
slash.

So, how does one get the above example to print out all words in the
list??


I thought that maybe regular expressions was the way to go, however I
can't even get the regular expression example given in the user guide to
work.

function print regexp [match_mask \\(.*\\)\\.c blah.c foo];

The result is:

cook: regexp

That is, nothing is matched.  Why is this so?


Thanks in advance for any help.


Matt Lee
KlaxonIQA
Sydney, Australia



More information about the Cook-users mailing list