in reply to Re: The same pattern searching
in thread Replacing the pattern
Like for the above case the code will not work. I had tried this code before also. I had made the pattern for the above cases asabc The pattern follows <page> 24 def
But the above patterns are just lacking in the counting the no. of lines if found in the data, that should be converted into spaces. I hope that now u have a clear picture of the problem.$pattern='(\n\s*[0-9]{1,3}\s*\n\s*<page>\s*\n)'; if ($target_data =~ /$pattern/gi) { $target_data =~ s/$pattern/" " x length($1)." " x length($2)." " x len +gth($3)." " x length($4)/gie; } $pattern='(\n\s*-[0-9]{1,3}-\s*\n\s*<page>\s*\n)'; if ($target_data =~ /$pattern/gi) { $target_data =~ s/$pattern/" " x length($1)/gie; } $pattern='(\n\s*[A-Za-z]-[0-9]{1,3}\s*\n\s*<page>\s*\n)'; if ($target_data =~ /$pattern/gi) { $target_data =~ s/$pattern/" " x length($1)/gie; } $pattern='(\n\s*page\s*[0-9]{1,3}\s*of\s*[0-9]{1,3}\s*\n)'; if ($target_data =~ /$pattern/gi) { $target_data =~ s/$pattern/" " x length($1)/gie; }
|
|---|