in reply to Re: Re: string substitution
in thread string substitution
First pass does the HELL -> BAD substitution based on word boundries. So far none of your examples have shown characters that are not either mathematical symbols, alpha, or space. So I'm not going to waste your time with worrying about whether BAD is next to a mathematical symbol. If your examples showed non-mathematical symbols, then I'd worry about that part again.$string =~ s/\bHELL\b/BAD/g; $string =~ s/(?<\W)\s|\s(?=\W)//g;
The second pass removes any whitespace that has a non-word character on one side or the other of it. That will get rid of the space between BAD and +, but not between REALHELL and REALHELL.
Until we know what you're really trying to do we will continue playing the guessing game and falling short of your needs. Be sure to read perlretut and perlre. It's your turn to come up with a solution.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: string substitution
by Anonymous Monk on Oct 09, 2003 at 19:16 UTC |