Converting space- to tab-delimited

Alex Tweedly alex at
Mon Feb 28 13:20:34 CST 2005

Gregory Lypny wrote:

> I would greatly appreciated your help with choosing the regular 
> expression I need to use in replaceText in order to convert a text 
> file from space delimited to tab delimited when the number of spaces 
> between words is not constant.
> Here's an example of one line of input data.
> word1 [3 spaces] word2 [5 spaces] word3 [2 spaces] cr
> I'd like to convert that to
> word1 [tab] word2 [tab] word3 [tab]
replaceText(tString, " +", TAB)

Note that is 2 characters : space and +

For example

> put replacetext("asd   qwe werer          z", " +", ",")


> asd,qwe,werer,z

btw - Do you need to do anything special with a line like
[3 spaces] word1 [2 spaces] word2

The above replacetext will give
TAB word1 TAB word2 cr
which is probably what you want - but worth thinking about as a 
potential special case.

Alex Tweedly

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.1 - Release Date: 27/02/2005

More information about the use-livecode mailing list