yokelrobin
08-05-2004, 02:33 PM
I need to replace some spaces with commas so that the data can be imported into a spreadsheet.
Normally this would be easy, using Replace(), but in this case, I need to only replace some spaces.
The text string has a random number of spaces in it, and I need to replace the first space and the last three spaces with commas.
For example:
a bcd efg hij klm nop qrs tuv wxy z
Would need to be changed to:
a,bcd efg hij klm nop qrs,tuv,wxy,z
It might also look like this:
a bcde fghijklmn pqr stu vwxyz
which would need to be changed to:
a,bcde fghijklmn,pqr,stu,vwxyz
(to demonstrate random numbers of spaces!)
Any ideas anyone? I'm sure there's a way, but just not sure how exactly!
Thanks in advance.
Normally this would be easy, using Replace(), but in this case, I need to only replace some spaces.
The text string has a random number of spaces in it, and I need to replace the first space and the last three spaces with commas.
For example:
a bcd efg hij klm nop qrs tuv wxy z
Would need to be changed to:
a,bcd efg hij klm nop qrs,tuv,wxy,z
It might also look like this:
a bcde fghijklmn pqr stu vwxyz
which would need to be changed to:
a,bcde fghijklmn,pqr,stu,vwxyz
(to demonstrate random numbers of spaces!)
Any ideas anyone? I'm sure there's a way, but just not sure how exactly!
Thanks in advance.