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
In reply to Re^3: Regex (?{ code }) and use re 'eval'
by mwah
in thread Regex (?{ code }) and use re 'eval'
by SFLEX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |