$variable = "-----;=99;helloworld"; if ($variable =~ /(\d\d)/) { # $1 contains 99 }