I've encountered a problem using regex.replace with accented words - I'm using regex replace because I need to replace complete and not partial strings (see 'grund' in list).
But AHK seems to ignore accented characters at the beginning and end of words (in the middle it's fine). Has anyone come across this problem before?
I came up with the following "fix", by adding an underscore before leading accented characters after after trailing accented characters, but it still doesn't work correctly when an accent appears within a word (see 'mémit' and mèmit'). Could someone please help? I'm sure there's a much easier way to deal with accents!
Cheers!
^+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