My script is required to insert pattern (?:<\/?[a-z\-\=\"\ ]+>)?
in words after each letter which can be used in another regular expression.
Problem is that is some words their may be regex pattern like .*?
or (?:<[a-z\-]+>)
. I tried it but error thows unmatched regex
where my pattern adds after (
or space created in regex causing this problem. Any help.
Here is the code I tried:
sub process_info{
my $process_mod = shift;
#print "$process_mod\n";
@b = split('',$process_mod);
my $flag;
for my $i(@b){
#print "@@@@@@@@ flag: $flag test: $i\n";
$i = "$i".'(?:<\/?[a-z\-\=\"\ ]>)?' if $flag == 0 and $i !~ /\\|\(|\)|\:|\?|\[|\]/;
#print "$i";
if ($i =~ /\\|\(|\)|\:|\?|\[|\]/){
$flag = 1;
}
else{
$flag = 0;
}
#print "After: $i\n";
}
$process_mod = join('',@b);
#print "$process_mod\n";
return $process_mod;
}