Schrift
[thread]8439[/thread]

Regexp 32 Bit Limitierung



<< |< 1 2 >| >> 15 Einträge, 2 Seiten
bloonix
 2006-10-20 15:52
#71042 #71042
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Hallo Leute,

Code: (dl )
$text  =~ s/^(.{50000}).*$/$1/;


Quantifier in {,} bigger than 32766 in regex; marked by <-- HERE in m/^(.{ <-- HERE 50000}).*$/ at /var/www/common/cgi-bin/new.cgi line 42.

Gibt es fuer dieses Problem ein Modul? Wenn ich auf 32766 Zeichen
limitiere, laeuft das Skript mit weniger Bits trotzdem auf Fehler.

Gruss,
opi
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
esskar
 2006-10-20 15:58
#71043 #71043
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
was willst du denn matchen?
renee
 2006-10-20 16:14
#71044 #71044
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
So könnte man das umgehen:
Code: (dl )
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl

use strict;
use warnings;

my $string = 'a' x 50_000 . 'skjd';
my $regexp = qr-^((.){32000}\2{18000})skjd$-;

print "yes\n" if $string =~ /$regexp/;


Edit: natürlich geht'ts noch einfacher:
Code: (dl )
my $regexp = qr-^((.{25000}){2})skjd$-;


Edit2: Dein .*$ im Regulären Ausdruck ist überflüssig. Das matcht ja auf alles...\n\n

<!--EDIT|renee|1161346568-->
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/
nepos
 2006-10-20 16:23
#71045 #71045
User since
2005-08-17
1420 Artikel
BenutzerIn
[Homepage] [default_avatar]
Hm, wenn du die ersten 50000 Zeichen haben willst, dann kannst du das auch anders machen.
bloonix
 2006-10-20 16:24
#71046 #71046
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Beispiel bei 3 Zeichen:

Code: (dl )
1
2
3
$text = 'text ist zu lang';
$text =~ s/^(.{3}).*$/$1/;
print $text, "\n";


tex

Ich möchte einen Text auf eine vorgegebene Länge kürzen.

@renee, wenn ich .* weglasse, wird der Text nicht gekürzt
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
esskar
 2006-10-20 16:30
#71047 #71047
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
1
2
3
if(length($text) > 3) {
$text = substr($text, 0, 3);
}
bloonix
 2006-10-20 16:33
#71048 #71048
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Ach ja, um mein eigentliches Problem nochmal zu schildern...

Mein OS ist ein 32 Bit. Was ist aber, wenn das Skript auf einem OS mit
weniger ausgeführt wird? Dann läuft es dort ebenfalls auf Fehler...

Ich dachte, dass es da vielleicht ein Modul gibt, dass genau auf sowas
achtet... wenn nicht, mit welchem kleinsten Wert sollte ich arbeiten um
sicher gehen zu können?
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
bloonix
 2006-10-20 16:34
#71049 #71049
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
@esskar, danke, substr() hat keine Limitierung!

Hätte ich eigentlich auch dran denken können! :)

@others, danke für eure Aufmerksamkeit!\n\n

<!--EDIT|opi|1161347972-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
renee
 2006-10-20 16:41
#71050 #71050
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
[quote=opi,20.10.2006, 14:24]@renee, wenn ich .* weglasse, wird der Text nicht gekürzt[/quote]
Ich habe das s/// übersehen... Ich war von einem einfachen match ausgegangen...
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/
esskar
 2006-10-20 16:46
#71051 #71051
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=opi,20.10.2006, 14:33]Mein OS ist ein 32 Bit.[/quote]
läuft perl auf 16-bit systemen?
wer benutzt noch 16-bit systeme?
<< |< 1 2 >| >> 15 Einträge, 2 Seiten



View all threads created 2006-10-20 15:52.