从BrightScript字符串中删除空格

dan*_*tch 2 brightscript

我试图使用正则表达式从我的字符串中删除前导和尾随空格

regexQuote = CreateObject("roRegex", "/^[ ]+|[ ]+$/g+", "i")
regexQuote.ReplaceAll(noSpaceString)
print noSpaceString
Run Code Online (Sandbox Code Playgroud)

[编辑]

regexQuote = CreateObject("roRegex", "/^[ ]+|[ ]+$/g", "")
print len(noSpaceString) //this value includes leading white spaces, which I dont want
Run Code Online (Sandbox Code Playgroud)

我也试过了

regexQuote = CreateObject("roRegex", "/^[ ]+|[ ]+$/", "")
Run Code Online (Sandbox Code Playgroud)

并尝试过

regexQuote = CreateObject("roRegex", "/(^\s*)|(\s*$)/", "")
Run Code Online (Sandbox Code Playgroud)

Nas*_*nov 6

使用 trim()

使用trim(),卢克!有一个字符串方法只是为了这个目的:

BrightScript Debugger> ? len("   four   ".trim())
 4
Run Code Online (Sandbox Code Playgroud)