【发布时间】:2014-10-23 05:43:18
【问题描述】:
我在使用带有重音符号的 regex.replace 时遇到了问题 - 我正在使用 regex replace 因为我需要替换完整而不是部分字符串(请参阅列表中的“grund”)。
但 AHK 似乎忽略了单词开头和结尾的重音字符(中间没问题)。有没有人遇到过这个问题?
我想出了以下“修复”,通过在尾随重音字符之后在前导重音字符之前添加下划线,但是当单词中出现重音时它仍然无法正常工作(请参阅'mémit' 和 mèmit' )。有人可以帮忙吗?我确信有一种更简单的方法来处理口音!
干杯!
^+f2::
data =
(
testé = WORD1
kragén = WORD2
und = WORD3
gürtel = WORD4
émail = WORD5
élder = WORD7
messé = WORD8
émit = WORD9
èmit = WORD10
testè = WORD11
)
text =
(
testé kragén und gürtel émail nomâtch élder messé émit émit èmiter émita mémit mèmit testé testè grund
)
text := RegExReplace(text,"(\w+é)\W|$","$1_ ")
text := RegExReplace(text,"\W(é\w+)"," _$1")
text := RegExReplace(text,"(\w+è)\W|$","$1_ ")
text := RegExReplace(text,"\W(è\w+)"," _$1")
loop, parse, data, `n, `r
{
stringsplit, term, a_loopfield, =, %a_space%
text := RegExReplace(text, "\b" . term1 . "\b", term2)
}
stringreplace, text, text, _, , all
stringreplace, text, text, _ , , all
msgbox, % text
return
【问题讨论】:
标签: regex autohotkey