#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $string = 'WhateverFooBlahBarMoreFooStuffBarMore'; my @words = $string =~ / (?<=Foo) (.*?) (?=Bar) /gx; print Dumper \@words;