2012-01-09 52 views
0

我需要使用Sensetalk(Eggplant GUI测试程序使用的脚本语言)解析和分隔文本字符串。我希望能够做的是提供代码的文本字符串:茄子/ Sensetalk解析并用大写字母分隔字符串

Put "MyTextIsHere" into exampleString 

然后有充分的大写字母节省第一前插入空格,所以下面然后存储在exampleString

"My Text Is Here" 

我基本上想把字符串分成它包含的单词。在搜索文档和网页后,我不再接近寻找解决方案(我同意,用另一种语言 - 唉,不是我的选择会容易得多)。

预先感谢任何能提供一些见解的人!

回答

2

查看http://www.testplant.com/phpBB2/viewtopic.php?t=2192的问题。

随着信贷帕梅拉在TestPlant论坛:

set startingString to "HereAreMyWords" 
set myRange to 2 to the number of characters in startingString // The range to iterate over– every character except the first 

Put the first character in startingString into endString // The first character isn't included in the repeat loop, so you have to put it in separately 

repeat with each character myletter of characters myRange of startingString 
    if charToNum(myLetter) is between 65 and 90 // if the character's unicode number is between 65-90... 
     Put space after endString 
    end if 
    Put myLetter after endString 
end repeat 

put endString 

,或者你可以这样来做:

Put "MyTextIsHere" into exampleString 
repeat with each char of chars 2 to last of exampleString by reference 
    if it is an uppercase then put space before it 
end repeat 
put exampleString