找回密码
 加入
搜索
查看: 1601|回复: 3

[网络通信] StringStripWS不能去除的空白?[已解决]

[复制链接]
发表于 2021-8-9 22:59:54 | 显示全部楼层 |阅读模式
本帖最后由 cashiba 于 2021-8-9 23:58 编辑
Local $Str='  Is not between life and death'

$Str = StringStripWS($Str, 7)
ConsoleWrite("[" & $Str & "]" & @CRLF)
[  Is not between life and death]
今天用StringStripWS整理文本,发现有些空白无法去除。
经转换原始文本发现,该空白的ascii码是Chr(161)
ASCII( )=Chr(161)        UNDEC( )=ChrW(12288)
ASCII( )=Chr(161)        UNDEC( )=ChrW(12288)
这种类似的情况该如何处理?.


原网页编码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


复制的文本如下:


  The furthest distance in the world

  Is not between life and death

  But when I stand in front of you

  Yet you don’t know that I love you

  世界上最遥远的距离

  不是生与死之间的距离

  而是我站在你面前

  你却不知道我爱你

  The furthest distance in the world

  Is not when I stand in front of you

  Yet you can’t see my love

  But when undoubtedly knowing the love from both

  Yet cannot be together

  世界上最遥远的距离

  不是我站在你面前

  你却看不到我对你的爱

  而是感受到对方坚定的爱意

  却不能在一起

  The furthest distance in the world

  Is not being apart while being in love

  But when plainly cannot resist the yearning

  Yet pretending you have never been in my heart

  世界上最遥远的距离

  不是相爱的人不能在一起

  而是明明不能停止思念

  却装作对方从未走进自己心间

  The furthest distance in the world

  Is not but using one’s indifferent heart

  To dig an uncrossible river

  For the one who loves you

  世界上最遥远的距离

  是用冷漠的心

  为爱你的人

  挖掘一条无法穿越的鸿沟

发表于 2021-8-9 23:14:20 | 显示全部楼层
用正则试试
StringRegExpReplace($Str, '^\h+|\h+(?=\h)|\h+$', '')
 楼主| 发表于 2021-8-9 23:22:15 | 显示全部楼层

A大的正则很完美,没问题。

难道这个内置函数不是使用的正则方法处理的?
还没有A大的方法好用

谢谢A大!
发表于 2021-8-10 11:15:06 | 显示全部楼层
A大的正则如神一般
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-2 17:46 , Processed in 0.072877 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表