【问题标题】:Unexpected behavior from _StringExplode()_StringExplode() 的意外行为
【发布时间】:2015-07-31 05:24:15
【问题描述】:

我有一个字符串:string1 string2 - string3 string4。我需要在- 处将它分成两部分(注意“-”两边的空格)。我有以下代码没有按预期工作:

#include <MsgBoxConstants.au3>
#include <String.au3>

Local $test = _StringExplode("string1 string2 - string3 string4", " - ")

MsgBox($MB_SYSTEMMODAL, "Title", $test[1])

输出为string2。我希望它是string3 string4

一定是一个小小的疏忽,但我很难找到它。

【问题讨论】:

    标签: split autoit


    【解决方案1】:

    …解释我做错了什么…

    它是a bug concerning AutoIt v3.3.12.0(已在后续测试版中解决)。或者可以使用StringSplit()

    #include <MsgBoxConstants.au3>
    #include <StringConstants.au3>
    #include <Array.au3>
    
    Global Const $g_aTest = StringSplit('string1 string2 - string3 string4', ' - ', $STR_ENTIRESPLIT)
    
    MsgBox($MB_SYSTEMMODAL, 'Title', $g_aTest[2])
    _ArrayDisplay($g_aTest)
    

    包含$STR_NOCOUNTStringSplit() 的标志参数返回与_StringExplode() 相同的数组。

    【讨论】:

      猜你喜欢
      • 2020-10-04
      • 2016-07-16
      • 2016-05-10
      • 2020-07-23
      • 2021-08-23
      • 2021-11-16
      • 2017-10-20
      • 2016-06-29
      • 2017-07-24
      相关资源
      最近更新 更多