#!/usr/bin/perl use strict; use warnings 'all'; my $a = "my.col like 'xyz'"; # oder "irgendwas and table.column like 'irgendwas' and irgendwas" # oder "table.column like 'irgendwas' and irgendwas" # oder "irgendwas and table.column like 'irgendwas'" @a = $a =~ /^(.+? and )?(\w+\.\w+) like ('.*?')( and .*)?$/; for (1..@a) { print "$_: ". ($a[$_-1] or "(undef)") ."\n"; }