use strict; use warnings; my $item1 = 'this is a test /test123?'; my ($content) = $item1 =~ m{ / (.*) \? }x; print "$content\n" if defined $content;