英文:
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]**
> **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::—
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论