Leser: 2
|< 1 2 3 >| | 27 Einträge, 3 Seiten |
$data =~ s/(\d+)/<font color=\"#ff0000\">$1<\/font>/gi
$data =~ s/(\d+)([^>]*(?:<|$))/<font color=\"#ff0000\">$1<\/font>$2/
1
2
3
4
5
6
7
<font color="#000000"><pre>
<br>"Hallo"
<br>1234<br>214214<br>346<br>
<br>
<br>();
<br>("Test! 2134",12421<br>
);</pre></font>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Parser;
# specify events here rather than in a subclass
my $p = HTML::Parser->new( api_version => 3,
text_h => [\&text,"text"],
default_h => [sub { print shift }, "text"],
);
sub text{
my ($text) = @_;
$text =~ s~(\d+)~<test>$1</test>~g;
print $text;
}
while (<>) {
$p->parse($_);
}
$p->eof;
1
2
3
4
5
6
7
<font color="#000000"><pre>
<br>"Hallo"
<br>1234<br>214214<br>346<br>
<br>
<br>();
<br>("Test! 2134",12421<br>
);</pre></font>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl -w
$file = shift;
$/ = undef;
open FILE, "<", $file;
$_ = <FILE>;
close FILE;
while ( not m/\G\z/gc )
{
if ( m/\G(<(?>[^>"]|"[^"]*")*>)/gc ) { print "$1"; }
elsif ( m/\G(\d+)/gc ) { print "<font color=red>$1</font>"; }
elsif ( m/\G([^<\d]*)/gc ) { print "$1"; }
else
{
$loc = pos($file);
die "Fehler an Position $loc in Datei $file\n";
}
}
./zahlrot.pl zahlrot.txt
1
2
3
4
5
6
7
<font color="#000000"><pre>
<br>"Hallo"
<br><font color=red>1234</font><br><font color=red>214214</font><br><font color=red>346</font><br>
<br>
<br>();
<br>("Test! <font color=red>2134</font>",<font color=red>12421</font><br>
);</pre></font>
|< 1 2 3 >| | 27 Einträge, 3 Seiten |