That regex will isolate exactly one occurrence of " " per line within $text, and will ignore all other occurences of pattern on the same line -- in fact, the logic of the initial ".*" wildcard match will consume all but the last " ".$text =~ s/(.*)$nbsp(.*)//g; # this is your problem
Maybe you want something like this:
Note that this executes a "tr///" within the replacement part of the s{}{} regex, to change the non-space characters to dots; it applies equally to all lines, whether they have "nbsp" in them or not (and for lines that do have nbsp, it applies to each occurrence in succession, as well as the portion of the line that follows that last nbsp, if any).$text = "test of this # ? my 0923 5834t674"; $text =~ s{(.*?)(\ )?}{($x=$1)=~tr/ /./c; "$x$2"}ge; print "$text\n"; __OUTPUT__ .... .. .... . . .. .... ........
In reply to Re: Blanks with pre tag exceptions
by graff
in thread Blanks with pre tag exceptions
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |