I'm trying to emoji unicodes from text. For example
""Sepedanya biasa, spiritnya mantap jiwaaa" <U+0001F601><U+0001F6B4><U+0001F6B4> Bertumbuhlah, lebih sehat, lebih kuat, entah jasmani, rohani, atau relasi-relasi (persahabatan, kekerabatan, pernikahan, pekerjaan). Mulailah dari yg ada, jgn tunggu lengkap sarananya atau tepat situasinya. Mulai dan tekuni saja salah satunya, yg lain akan mengikut pd waktunya. Jangan menyerah kalau jatuh atau kambuh. Itu proses bertumbuh yg harus dikayuh, rute merupa Kristus yg layak ditempuh.
I want to extract all the U+ codes in this string and as well apply to a dataframe. Thank you
library(stringr)
text = "Sepedanya biasa, spiritnya mantap jiwaaa <U+0001F601><U+0001F6B4><U+0001F6B4>
Bertumbuhlah, lebih sehat, lebih kuat, entah jasmani, rohani, atau relasi-relasi
(persahabatan, kekerabatan, pernikahan, pekerjaan). Mulailah dari yg ada, jgn tunggu
lengkap sarananya atau tepat situasinya. Mulai dan tekuni saja salah satunya,
yg lain akan mengikut pd waktunya. Jangan menyerah kalau jatuh atau kambuh.
Itu proses bertumbuh yg harus dikayuh, rute merupa Kristus yg layak ditempuh"
unicodes = str_match_all(text, "<(U+[^\\>]+)>")
location = str_locate_all(text, "<(U+[^\\>]+)>")
unicodes = cbind(data.frame(unicode = unicodes[[1]][,2]), location[[1]])
unicodes
#> unicode start end
#> 1 U+0001F601 42 53
#> 2 U+0001F6B4 54 65
#> 3 U+0001F6B4 66 77
I used the str_match_all() function to extract all the unicodes based on the pattern of <U+ ... > then used the str_locate_all() with the same pattern to get the start and end location of each (should you like to know that too).