Apostrophe regex matching in autohotkey script

I have an autohotkey script that searches for a word in a bilingual dictionary when I double-click any word on a webpage. If I click on something like "l'homme", l will be copied to the clipboard, as well as to homme. I want the authotkey script to delete everything and down to the apostrophe.

I cannot get autohotkey according to apostrophe. The following is an example script that displays the ascii values โ€‹โ€‹of the first four characters. If I double-clicked "l'homme" on this page , it gives: 108,8217,104,111. The second character is clearly not an ascii code for the apostrophe. I think this is most likely due to the HTML representation of the apostrophe, but I could not figure it out. I tried using autohotkey transform, an HTML function with no luck.

I tried both Unicode and non-Unicode versions of autohotkey. I saved the script in UTF-8.

#Persistent return OnClipboardChange: ;debugging info: c1 := Asc(SubStr(clipboard,1,1)) c2 := Asc(SubStr(clipboard,2,1)) c3 := Asc(SubStr(clipboard,3,1)) c4 := Asc(SubStr(clipboard,4,1)) Msgbox 0,info, char1: %c1% `nchar2: %c2% `nchar3: %c3% `nchar4: %c4% ;the line below is what I want to use, but it doesn't find a match stripToApostrophe:= RegExReplace(clipboard,".*'") 
+4
source share
1 answer

There is a standard quote ' and there is a quote' curling ' . '

Maybe your regex should be

 .*[''] 

to cover both cases.

Perhaps you would like to make this non-greedy if the word can have more than one apostrophe and you want to delete only the first:

 .*?[''] 

EDIT:

Interesting. I tried this:

 w1 := "l'homme" w2 := "l'homme" c1 := Asc(SubStr(w1,2,1)) c2 := Asc(SubStr(w2,2,1)) v1 := RegExReplace(w1, ".*?['']") v2 := RegExReplace(w2, ".*?['']") MsgBox 0,info, %c1% - %c2% - %v1% - %v2% return 

And returned 146 - 39 - homme - homme . I am editing from Notepad. Is it possible that our regular expression, while we think that we are dialing 8217, actually has 146 on our inset?

EDIT:

Obviously, Unicode support was added only for AutoHotkey_L . Using this, I believe that the correct regular expression should be either

 ".*?[\x{0027}\x{0092}\x{2019}]" 

or

 ".*?(" Chr(0x0027) "|" Chr(0x0092) "|" Chr(0x2019) ")" 
+3
source

Source: https://habr.com/ru/post/1432957/


All Articles