How to replace unicode string? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wgf4242
Posts: 9
Joined: 25 Apr 2015, 09:05

How to replace unicode string?

Post by wgf4242 » 26 Nov 2022, 17:30

Code: Select all

MsgBox % RegExReplace("🐴に한", "[\x{dddd}-\x{ffff}]" , "horse") ; emoji
; expected: horseに한
Only remove horse or other emoji.

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: How to replace unicode string?

Post by mikeyww » 26 Nov 2022, 18:07

Code: Select all

emojiList := {horse: "🐴"}
str        = 🐴に한
For text, emoji in emojiList
 str := RegExReplace(str, emoji, text)
MsgBox, 64, Result, %str%

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How to replace unicode string?  Topic is solved

Post by flyingDman » 26 Nov 2022, 18:51

Or:

Code: Select all

MsgBox % RegExReplace("🐴に한", "\x{1F434}" , "horse")        ; U+1F434 code for this horse
;or
MsgBox % RegExReplace("🐴に한", chr(128052) , "horse")
but the OP might want to replace any emoji hence the [ - ]. OP to clarify if (s)he wants to replace the "horse" word with other words. If not it might be possible to loop without having to provide the details of each emoji but rather loop through numbers.
14.3 & 1.3.7

Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to replace unicode string?

Post by Rohwedder » 27 Nov 2022, 02:15

Hallo,
such a loop could be long!

Code: Select all

emojiList := {"couple with heart: woman, woman, dark skin tone": "👩🏿‍❤️‍👩🏿"}
Full Emoji List, v15.0

Post Reply

Return to “Ask for Help (v1)”