#!/usr/bin/env perl use warnings; use strict; my $NetName = 'top_level/mbist_wrapper_pix2d[22]'; my $NetPattern = 'mbist[\w+\d+\/]*\[\d+\]'; if ($NetName =~ qr/$NetPattern/x) { print "match\n"; } else{ print "no match\n"; }