#!/usr/bin/perl use strict; use warnings; my $string = "abcABC123ABCabc"; # the following is using shell commands # to do something perl can do much better... echo `expr match "$string" 'abc[A-Z]*.2'` ; echo `expr match "$string" 'abc[A-Z]*2'` ;