Converting space- to tab-delimited
Ken Ray
kray at sonsothunder.com
Mon Feb 28 20:35:23 EST 2005
On 2/28/05 2:51 PM, "Alex Tweedly" <alex at tweedly.net> wrote:
> RegEx allows the "unix-style" (or C-style, or Perl-style) quoting of
> special characters, so "\s" means "(space)" - so the two versions of
> "\s+" and " +" are effectively the same - choose whichever you find
> easier to read.
No to be pedantic, but just to clarify:
\s means "any whitespace character", which can be a space, a tab, a
carriage return, a linefeed or a formfeed.
However for this purpose, Alex is right - the two are effectively the same.
The only time you'd want to choose one over the other is if you cared to
deal with different kinds of whitespace in the same string. So:
put "Ken" & linefeed & "Alex Frederic" & CR & "James" into tText
put replaceText(tText," +",tab)
--> Ken <linefeed> Alex <tab> Frederic <CR> James
put replaceText(tText,"\s+",tab)
--> Ken <tab> Alex <tab> Frederic <tab> James
Hope this helps,
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list