0

我使用 Autohotkey(版本 1.0.48.05)和 HiEdit 控件制作了一个编辑器。我努力实现的一个功能是从文本块中修剪空白 - 而不删除空行。

如何停止以下 RE 删除空行:

块 := RegExReplace(块,"m)\s*$","")

块 := RegExReplace(块,"m)^\s*","")

提前谢谢了。

G

亲爱的阿卜杜勒,

伟大的 [ \t] 对我的探针进行了排序。我现在知道 \s 匹配 EOL,而 [ \t] 或 [:BLANK:] 不匹配。非常感谢您的帮助

G

4

2 回答 2

2

尝试使用[:blank:]or[ \t]代替\s.

于 2012-12-18T13:14:58.680 回答
0

为什么要使用正则表达式?

VarSetCapacity(fir, 20)  ; Ensure the variable is large enough to accept the new string.
fir.="text`nhello`n`n`n`n`n"

DllCall("Shlwapi.dll\StrTrim", "Str", fir, "Str", " `r`n",  "Cdecl")  ; Requires the Cdecl calling convention.
MsgBox, % fir

似乎也有效

于 2021-02-26T11:19:58.780 回答