如何在AutoHotKey中替换文本,但仅当needle的大小写与ReplaceText完全匹配时。

huangapple go评论47阅读模式
英文:

How to replace text in AutoHotKey but iff. the needle matches the exact capitalization of the ReplaceText?

问题

## 代码 ##

    #NoEnv
    #SingleInstance, Force
    #Warn
    SendMode, Input
    SetBatchLines, -1
    SetWorkingDir, %A_ScriptDir%
    StringCaseSense, 1
    
    :*?:EmDash::—
<hr>

## 解释 ##

我的目标是将文本“EmDash”替换为—,但只有在文本正好拼写为“EmDash”时才能替换,不是emdash或除了完全一样之外的任何其他拼写。目前的代码可以替换emdash为—,但这不是我的目标。我已尝试使用“StringCaseSense, 1”来解决这个问题,但没有成功。如果有人知道答案,请在这里分享。我在任何论坛上都没有找到这个问题的答案。
英文:

Code

#NoEnv
#SingleInstance, Force
#Warn
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
StringCaseSense, 1

:*?:EmDash::—

<hr>

Explanation

My goal is to replace the text "EmDash" with —, but only if the text is spelt exactly as "EmDash", not emdash or any other spelling except exactly that. The code currently works for replacing emdash with —, but this is not my goal. I have tried to solve this by using "StringCaseSense, 1", but to no avail. If anyone knows the answer please share it here. I have not found the answer to this problem on any forum.

答案1

得分: 1

Sure, here is the translated code snippet:

**[选项 区分大小写:][1]**
&gt; **C**: 当您键入缩写时,它必须与脚本中定义的大小写完全匹配。使用 C0 来关闭大小写敏感性。

    :c*?:EmDash::—
    
[1]: https://www.autohotkey.com/docs/v1/Hotstrings.htm#C

Please note that I have provided the translated part as per your request, and I didn't translate the code portions.

英文:

Option Case sensitive:
> C: When you type an abbreviation, it must exactly
> match the case defined in the script. Use C0 to turn case sensitivity
> back off.

:c*?:EmDash::—

huangapple
  • 本文由 发表于 2023年4月10日 20:41:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75977207.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定