in reply to Re^2: Regex (?{ code }) and use re 'eval'
in thread Regex (?{ code }) and use re 'eval'
i want to take a hash of simple regex ie(0-9, a-z) and match them in square brackets/box brackets
Under these conditions, your "example 6" would look sth. like:
use strict; use warnings; my %Build = ( jj => '0-9', kk => 'a-z', ); my $message = '[445] [5353453] [fff] [445]'; my $message6 = $message; while( my ($k,$v) = each %Build) { my %speed_fix; if(my @re_match = $message6 =~ m{ (?<=\[) [$v]+ (?=\]) }xisg ) { foreach my $m_check (@re_match) { next if $speed_fix{$m_check}; if( my $built = return_number($m_check) ) { $message6 =~ s{ \[ $m_check \] }{$built}xisg; ++$speed_fix{$m_check}; } } } } print "$message6\n"; sub return_number { my $numbers = shift; return $numbers; }
Maybe one could delete more stuff - if you could provide an exact specification of the problem.
Regards
mwa
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Regex (?{ code }) and use re 'eval'
by SFLEX (Chaplain) on Nov 21, 2007 at 20:04 UTC | |
by ikegami (Patriarch) on Nov 21, 2007 at 20:07 UTC |