【问题标题】:Autohotkey Trim text with regular expressionAutohotkey 使用正则表达式修剪文本
【发布时间】:2021-02-26 19:19:58
【问题描述】:

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

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

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

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

非常感谢。

G

亲爱的阿卜杜勒,

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

G

【问题讨论】:

    标签: regex autohotkey


    【解决方案1】:

    尝试使用[:blank:] 或[ \t] 而不是\s。

    【讨论】:

      【解决方案2】:

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

      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
      

      好像也可以

      【讨论】:

        猜你喜欢
        • 2015-01-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-20
        • 1970-01-01
        • 2011-11-16
        相关资源
        最近更新 更多