Thread String formatieren: Regular Expressions (13 answers)
Opened by birkhauser at 2006-03-06 16:14

renee
 2006-03-06 18:31
#63502 #63502
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Gibt es irgendwie einen Anfangstag oder hast Du wirklich nur den String wie oben??

Dann könnte es so aussehen:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/bin/perl
use strict;
use warnings;
use HTML::Parser;

my $text = '';
my $string = "LDGPTLIVIQRTCXITQGLAFATAXYXNHYQSWZMNTNLLLIIYZQFWFLIEMZLVNHQM<span class='stil3'>B<\/span>IKECTWXFYKQTVHGMRM<span class='stil3'>B<\/span>YEHGAYTCXALGE<span class='stil3'>B<\/span>HRLGEKTFXQFAMCGLCTXCTCSLFLNINNDZTDCZRWLAKEDRHGPKYMNFQECCHRGFNPZ<span class='stil3'>B<\/span><span class='stil3'>B<\/span>WNRXQHYIGXWRRH<span class='stil3'>B<\/span>SFIGDYLNLW<span class='stil3'>B<\/span><span class='stil3'>B<\/span>LQLHLIKVWAVMDCZETV<span class='stil3'>B<\/span>XDDDKCLPKWKATTQZV<span class='stil3'>B<\/span>MLHAADMYF<span class='stil3'>B<\/span>ADA<span class='stil3'>B<\/span>LXSQIPP<span class='stil3'>B<\/span>ITZKTFGQNZIPRCLENXKAZZLFKKRWICCZDFMQDED<span class='stil3'>B<\/span>SCHXYLWKLCTVHRZAF<span class='stil3'>B<\/span>AZDPLFNIEEKGLTII<span class='stil3'>B<\/span>QPPQAYNRPY<span class='stil3'>B<\/span>HTSFCH<span class='stil3'>B<\/span>IXHFZQYPMHQSLPDRQXWVASR<span class='stil3'>B<\/span>KXELCMIZEKKDZMSHIPLY<span class='stil3'>B<\/span><span class='stil3'>B<\/span>AXYQGWIXNPKZXDWCTEEXFAAZMSSYNGVAZGLLNZEKVYDNANK<span class='stil3'>B<\/span>EQXXGVTHPKWRWYDGWPHXI<span class='stil3'>B<\/span>DSEA<span class='stil3'>B<\/span>MKLVWRTHVRHTEGQKCCFLXRYHFEZSQSFAHNRVCHMVTDPKN<span class='stil3'>B<\/span>CPENL<span class='stil3'>B<\/span>FQCKNDTGDKQKMMAFWHICTENCNQATQEADYZHDPZGDQNSW<span class='stil3'>B<\/span>DHSKCHKMXDCRWEXARFWYGKIACRMSMNL<span class='stil3'>B<\/span>YMVHGAGKYMPQQZHRFPDKERHFPXNHVQTCYMZKNMSXSPPNDDSSVLZWLZVKE<span class='stil3'>B<\/span>ENFERTYGPWSKDYHMCRQDDZAHDAARVLEGLYRTNGIWZZYVHKMLZRQVGECSLZ<span class='stil3'>B<\/span>RXETQCD<span class='stil3'>B<\/span>P<span class='stil3'>B<\/span>SFDGNHMMYNM<span class='stil3'>B<\/span>IRQYTYDMAVMZ<span class='stil3'>B<\/span>LIZGQIIXIGPLEPFYLXAYNPMXCEVVRAHKTQQQSGALCIYZDXPPAVLVDDRRWMWEGWSHPSQSVDZVMLFSTRZXLM
WTPHRWZQZIHYFQQVMLNGQDFSFIXREPWFRVATAZCFMTRYLZEFNATLQIRHTCLHNDVIEDYLSLHCNCLXGWFH<span class='stil3'>B<\/span>TK<span class='stil3'>B<\/span>FHWMHGRLRZPESKVC<span class='stil3'>B<\/span>KNWFLWLCILKFLPZZKLLMNSLNCFDGLHWXSGGM<span class='stil3'>B<\/span>DTQNCYD<span class='stil3'>B<\/span>QQX<span class='stil3'>B<\/span>TMTWDFSMHNYKIIIDPEFNZP<span class='stil3'>B<\/span>DCGTX";

my $p = HTML::Parser->new();
$p->handler(text => \&start_handler,"dtext");
$p->parse($string);

$text =~ s~[^A-Z]~~gs;
$text =~ s~([A-Z]{70})~$1<br />~sg;
$text =~ s~B~<span class='stil3'>B</span>~g;
print $text;

sub start_handler{
$text .= shift;
}


(ungetestet)
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 String formatieren: Regular Expressions