Suppose I wanted to replace emoji in a string with it's texuarl equivalent. I think I need to search for Unicodes, so for example convert , unicode 1F600, to wherever it occurs in the string...
What should the regex expression look like?
Regex emoji help
Moderator: Martin
Re: Regex emoji help
Just realised the forum converst them back! I meant:
I think I need to search for Unicodes, so for example convert "", unicode 1F600, to ": - )" (without the spaces or quotes!) wherever it occurs in the string...
What should the regex expression look like?
I think I need to search for Unicodes, so for example convert "", unicode 1F600, to ": - )" (without the spaces or quotes!) wherever it occurs in the string...
What should the regex expression look like?
Re: Regex emoji help
If you only need simple replace, using replace() is enough. Emoji should be recognized properly, just like other UTF-8 chars.
Using replaceAll() also work here, since it is only single (emoji) char.
Code: Select all
str = "hahahaha😀Funny 😀";
rep = replace(str, "😀", ":-)");
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Regex emoji help
Thanks. For the record, what would the regex syntax be?
Re: Regex emoji help
Surprisingly, the emoji itself can be used as the syntax. That's why replaceAll() also work there (replaceAll() is the regex version of replace() ). Try it in the regex tester, no need to escape it or using the unicode.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.