_StringExplode() 的意外行为 [英] Unexpected behavior from _StringExplode()

查看:34
本文介绍了_StringExplode() 的意外行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a string: string1 string2 - string3 string4. I need it split in two at the - (note the space on either side of the "-"). I have the following code which isn't working as expected:

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

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

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

输出是string2.我希望它是 string3 string4.

The output is string2. I expected it to be string3 string4.

一定是一个小疏忽,但我找不到它.

Must be a small oversight but I'm having trouble finding it.

推荐答案

…解释我做错了什么…

… explain what I'm doing wrong …

它是 有关 AutoIt v3.3.12.0 的错误(在后续测试版中解决).或者,可以使用 StringSplit():

It's a bug concerning AutoIt v3.3.12.0 (solved in successive beta). Alternatively StringSplit() can be used:

#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_NOCOUNT 包含到 StringSplit() 的标志参数返回与 _StringExplode() 相同的数组.

Including $STR_NOCOUNT to StringSplit()'s flag parameter returns array identical to _StringExplode().

这篇关于_StringExplode() 的意外行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆