Mark Schonewille wrote:
Hi JB,
Again, no regex. I looked into regex, but I can't find how to replace
quoted strings without knowing the whole string in advance. It would
be great if someone came up with a regex solution for this. In the
mean time, this function seems to do the job quite nicely:
function decentQuotes theStr
set the itemDel to space
repeat for each word myWord in theStr
if number of items of myWord > 1
then put quote & word 1 to -1 of (char 2 to -2 of myWord) & ¬
quote & space after myNewStr else put myWord & space after myNewStr
end repeat
return char 1 to -2 of myNewStr
end decentQuotes
Note that it assumes that strings are always surrounded by pairs of
quotes. Grammar errors are not taken care of.
I think it also assumes the input string is on a single line, since cr
is a word delimiter, so input like
first line
second line
becomes
first line second line
And input like ("."s to indicate where the spaces are ....)
first ".line..
..second.." line
get badly mangled into
first "line" second "lin"
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: 15/05/2006
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution