On 02/12/2019, at 06:38, @lbutlr <[email protected] <mailto:[email protected]>> wrote: > I asked someone how to remove all spaces in an string more efficiently and he > responded with > > search: (m?)\s+ > replace: (nul) > > which sure does work. > > But WHY?
On 02/12/2019, at 16:26, @lbutlr <[email protected] <mailto:[email protected]>> wrote: > On 12 Feb 2019, at 06:53, Rich Siegel <[email protected] > <mailto:[email protected]>> wrote: >> 'm guessing it was "(?m)\s+" > > That would make SLIGHTLY more sense, but it is definitely (m?)\s+ (I’ve > checked it a dozen times) Hey Lewis, That has to be a typo on your friend's part. There's no sense in adding a capture for an optional literal 'm' – it adds nothing and can mangle words ending in 'm'. This is test Maximum Text With some spaces ThisistestMaximuTextWithsomespaces I've no idea why the person in question might feel the need to turn ON multiline. (I'd guess habit.) Corrected: search: (?m)\s+ Turning OFF multiline works just the same: search: (?-m)\s+ #!/usr/bin/env perl -sw while (<>) { s!\s+!!g; print; } All produce your compressed string: ThisistestTextWithsomespaces > What I don’t get is that in the sample > > <<END > This is test > Text > With some spaces > END > > The result is > > ThisistestTextWithsomespaces > > Which is to say that it removes all the white space. All at once. In one > action. Were you were wanting to remove horizontal whitespace only? Find: \h+ Repl: null Vertical whitespace can be isolated with “\v”. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <https://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/bbedit.
