while ('abxxxacdxxxae' =~ /a([^x]+)/g) { say $1; } #### 'abcd' =~ /(.*) (?{ say $1 }) (?!)/sx