#!/usr/bin/perl use strict; use warnings; while () { chomp; print "with (?>): '$_' matches\n" if /_test(?>\s+)(?!<)/; print "without (?>): '$_' matches\n" if /_test\s+(?!<)/; } __DATA__ _test foo _test < _test < _test< #### with (?>): '_test foo' matches without (?>): '_test foo' matches without (?>): '_test <' matches