Converting space- to tab-delimited
Scott Rossi
scott at tactilemedia.com
Mon Feb 28 14:17:10 EST 2005
Recently, 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]
Can't answer for RegEx, but perhaps something like this brute force item
would work:
function spaceToTab pData
replace " " with tab in pData
repeat
if (tab & tab) is not in pData then exit repeat
replace (tab & tab) with tab in pData
end repeat
return pData
end spaceToTab
This would remove all spaces from the text -- not sure if that fits with
your needs.
Regards,
Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com
More information about the use-livecode
mailing list