Originally Posted by kurumi
use // instead of ". and your regex is wrong.
Please let's stop to address other members' solutions as wrong or worse. The difference between
is that the former uses a so-called dynamic regexp (even if it's actually a string constant), the latter uses a regexp constant. In both cases the expression is very simple and shouldn't bring to any problem, but there are some situations where the usage of one is preferred to the other. See http://www.gnu.org/software/gawk/man...mputed-Regexps
for an insight. Furthermore the additional anchor ^ is not really needed as per OP's requirements, since the M (if present) will be the first character in the last word
. Checking if it is present should be enough.
Please note the thread has been marked as solved by the OP, therefore let's add further information only if they are really valuable and give an actual improvement to the technical discussion. Thanks.