Regular expression match

Hi all,

any idea how to match the following:

char*<no or any string or space> buf and
char *<no or any string or space> buf
i need to capture the buf characters too.

currently i need two checks to cover this:

#search char* <any string> buf or char <any string> buf
@noarray = ($q =~ m/char\s*\*[\w\s]
\s([\w]+)/ig);
#search for char buf
@noarray2 = ($q =~ m/char\s*\
([\w]+)/ig);

any idea how to consolidate these two conditions into one statement?

how about:

    if (m#char\s*\*\s+(\w+)\s+(\w+)#) {
        print $1, "\t", $2, "\n";
    }

If you want to return the results to two different arrays that you don't want one regexp unless you also want to do more filtering of the data to know which array to send it to. Two regexp will be easier and probably faster. If you want just one array then can you post some real data examples and explain the data more if necessary because your current description is rather vague.