Thread RegEx Problem (13 answers)
Opened by Gast at 2006-12-01 16:06

PerlProfi
 2006-12-02 00:00
#72149 #72149
User since
2006-11-29
340 Artikel
BenutzerIn
[default_avatar]
Hier mal ein Beispiel Skript:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/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";
}


Ergebnis:
Code: (dl )
1
2
3
4
1: (undef)
2: my.col
3: 'xyz'
4: (undef)


MfG PerlProfi

View full thread RegEx Problem