No such thing as a small change | |
PerlMonks |
RegEx to filter \s not between labelsby gryphon (Abbot) |
on May 23, 2002 at 00:17 UTC ( [id://168622]=perlquestion: print w/replies, xml ) | Need Help?? |
gryphon has asked for the wisdom of the Perl Monks concerning the following question: Greetings fellow monks, This seems like such a simple problem, and perhaps it is and my brain is just extra slow today, but I need your help. I've got a rather long text string in a scalar from which I'd like to filter out multiple white spaces, converting them into just a single space per instance. Simple enough: $text =~ s/\s+/ /g;However, I'd like to not do this between a starting label and ending label. Here's some example text:
Basically, I'd love to have a simple regex that does the /\s+/ /og except not do anything between STARTPRESERVE and STOPPRESERVE. Any thoughts? (My appologies if this is really basic. I'm having a bad brain-day.) -gryphon
Back to
Seekers of Perl Wisdom
|
|