in reply to Re: The same pattern searching
in thread Replacing the pattern

Thanks Sasi but the above code doesn't solve my problem. As it is not the general problem for the all patterns found but it is just for the above example. As I had told earlier that the location of the pattern or the no. of lines in the pattern found is not fixed and there is no surity that the page no found could be only that way. The pattern found could be
abc The pattern follows <page> 24 def
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 as
$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; }
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.