Thread Regex arbeitet unvollständig
(14 answers)
Opened by sitescriptor at 2014-01-06 11:58
Geht:
Code (perl): (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 package Mooooo; use Modern::Perl; sub _analyse_ph { my $self = shift; my ($arg) = shift; chomp $arg; return "<!-- ### $arg ### -->"; }; sub new { my $this = shift; my $class = ref($this) || $this; my $self = {}; bless $self, $class; return $self; } my $Self = Mooooo->new; my $text; while ($text = <DATA>) { $text =~ s/__([-_\.a-zA-Z]+?(?:\(.+?\))*)__/$Self->_analyse_ph($1)/gme; say $text; } 1; __DATA__ __article.reldate.dayofmonth.html_selectscalar(0,1,31,article_reldate_dayofmonth)__ __article.reldate.month.html_selectscalar(0,1,12,article_reldate_month)__ __article.reldate.year.html_inputline(6,4,article_reldate_year)__ __article.id__ __article.autor__ ergibt: <!-- ### article.reldate.dayofmonth.html_selectscalar(0,1,31,article_reldate_dayofmonth) ### --> <!-- ### article.reldate.month.html_selectscalar(0,1,12,article_reldate_month) ### --> <!-- ### article.reldate.year.html_inputline(6,4,article_reldate_year) ### --> <!-- ### article.id ### --> <!-- ### article.autor ### --> Editiert von GwenDragon: Beispiel erweitert als package Last edited: 2014-01-06 12:33:38 +0100 (CET) |