Eggplant/Sensetalk 解析并分隔带有大写单词的字符串

发布于 2024-12-25 23:37:26 字数 371 浏览 3 评论 0原文

我需要能够使用 Sensetalk(Eggplant GUI 测试器使用的脚本语言)解析和分离文本字符串。我想要做的是为代码提供一个文本字符串:

Put "MyTextIsHere" into exampleString

然后在每个大写字母之前插入空格(保存第一个),因此以下内容将存储在 exampleString 中:

"My Text Is Here"

我基本上想要将字符串分成它包含的单词。在搜索文档和网络之后,我并没有更接近找到解决方案(我同意,使用不同的语言会容易得多 - 唉,不是我的选择)。

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

I'm in need of the ability to parse and separate a text string using Sensetalk (the scripting language the Eggplant GUI tester uses). What I'd like to be able to do is provide the code a text string:

Put "MyTextIsHere" into exampleString

And then have spaces inserted before every capital letter save for the first, so the following is then stored in exampleString:

"My Text Is Here"

I basically want to separate the string into the words it contains. After searching the documentation and the web, I'm no closer to finding a solution to this (I agree, it would be far easier in a different language - alas, not my choice).

Thank you in advance to anyone who can provide some insight!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不语却知心 2025-01-01 23:37:26

请参阅问题 http://www.testplant.com/phpBB2/viewtopic.php? t=2192

感谢 TestPlant 论坛上的 Pamela:

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

See question at http://www.testplant.com/phpBB2/viewtopic.php?t=2192.

With credit to Pamela at TestPlant forums:

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

or you could do it this way:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文