in reply to Need a regex to match C-style function arg list
Given the samples supplied, this does the trick. If your expressions can contain spaces, be split across lines or contain nested concats, then it will need further work.
#! perl -slw use strict; my $re_term = qr[[^,)]+?]; my $re_func = qr[\w+\($re_term,$re_term\)]; my $re_concat = qr[concat\((?:($re_func),($re_term|$re_func))\)]; while(<DATA>) { s[^$re_concat$][$1 & $2]; print; } __DATA__ concat(int2str(count,1),result) concat(bit2str(count,'10'B),result) concat(int2str(count,1),bit2str(count,'10'B))
Gives
c:\test>249976 int2str(count,1) & result bit2str(count,'10'B) & result int2str(count,1) & bit2str(count,'10'B)
|
|---|