if ( /^(\d*).+(\d*)$/ ) { # $1 containing the starting numeric string, if any. # $2 contains the terminating numeric string, if any. }