Thread Parsen eines Strings (aus einer Website) (13 answers)
Opened by drizzo at 2008-06-11 13:30

renee
 2008-06-11 15:07
#110968 #110968
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
rbaecker@www-devel-rbaecker ~$ cat regex.pl
#!/usr/bin/perl

use strict;
use warnings;

my $string = q~var cars=new Array();cars[0]=new Car('http://pic.autoscout24.net/images-small/984/101/0136101984001.jpg','8 Bilder','/Details.aspx?id=bd1vul43oeno',false,'. 7.500,-','. 0,-','','25.000','06/1978','37/50','37 kW / 50','Bugatti EB 110 replica','','','','D-81673','München','','','Weiß','Bugatti','EB 110','Benzin',false,'bd1vul43oeno','Schaltgetriebe',false,'',false,'','',false);cars[1]=new Car('http://pic.autoscout24.net/images-small/826/783/0130783826001.jpg','6 Bilder','/Details.aspx?id=bdu23n3wqbss',false,'. 14.890,-','. 0,-','','1','08/1977','44/60','44 kW / 60','Bugatti EB 110 Bugatti 35 Replika','','','','D-51588','Nümbrecht','','','Blau','Bugatti','EB 110','Benzin',false,'bdu23n3wqbss','',false,'',false,'','',false);cars[2]=new Car('http://pic.autoscout24.net/images-small/475/774/0054774475001.jpg','15 Bilder','/Details.aspx?id=fe22yo2zsbk',false,'. 229.000,-','. 0,-','','17.670','08/1994','412/560','412 kW / 560','Bugatti EB 110 EB 110 GT*Deutsche Auslieferung*','','ABS, Alarmanlage, Allrad, Elektr. Fensterheber, Klima, Klimaautomatik, Lederausstattung, Zentralverriegelung','','D-53498','Bad Breisig','','','blau','Bugatti','EB 110','Benzin',false,'fe22yo2zsbk','Schaltgetriebe',false,'',false,'','',false);cars[3]=new Car('http://pic.autoscout24.net/images-small/105/745/0064745105001.jpg','2 Bilder','/Details.aspx?id=ge2yzluzmgp',false,'. 1.295.000,-','. 0,-','','0','-','736/1001','736 kW / 1001','Bugatti EB 110 Veyron 16.4','','ABS, Airbag, Alarmanlage, Beifahrer Airbag, Bordcomputer, Elektr. Fensterheber, Elektrische Sitze, Klima, Klimaautomatik, Lederausstattung...','','D-46325','Borken','','','silber oder rot Metallic','Bugatti','EB 110','Benzin',false,'ge2yzluzmgp','Automatik',false,'',false,'','',false);~;

my @infos = split /new Car/, $string;
shift @infos;

my @cars;

for my $elem ( @infos ){
my @parts = $elem =~ /'([^']*?)'/g;
push @cars, [@parts[0,19,20,7,3]];
}

use Data::Dumper;
print Dumper \@cars;

rbaecker@www-devel-rbaecker ~$ perl regex.pl
$VAR1 = [
[
'http://pic.autoscout24.net/images-small/984/101/0136101984001.jpg',
'Bugatti',
'EB 110',
'06/1978',
'. 7.500,-'
],
[
'http://pic.autoscout24.net/images-small/826/783/0130783826001.jpg',
'Bugatti',
'EB 110',
'08/1977',
'. 14.890,-'
],
[
'http://pic.autoscout24.net/images-small/475/774/0054774475001.jpg',
'Bugatti',
'EB 110',
'08/1994',
'. 229.000,-'
],
[
'http://pic.autoscout24.net/images-small/105/745/0064745105001.jpg',
'Bugatti',
'EB 110',
'-',
'. 1.295.000,-'
]
];
rbaecker@www-devel-rbaecker ~$
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Parsen eines Strings (aus einer Website)