Processing text and characters

Text

Special characters

Author

Chi Zhang

Published

April 19, 2024

Patterns

# split by space, put in columns
stringr::str_split_fixed('Metronidazol Injection', '\\s+',2)
     [,1]           [,2]       
[1,] "Metronidazol" "Injection"
# a vector
v <- c('Metronidazol Injection', 'Gentamicin Injection')
stringr::str_split_fixed(v, '\\s+',2)
     [,1]           [,2]       
[1,] "Metronidazol" "Injection"
[2,] "Gentamicin"   "Injection"

Special characters

c('\u00E6', '\u00F8', '\u00E5')
[1] "æ" "ø" "å"
c('\u00C6', '\u00D8', '\u00C5')
[1] "Æ" "Ø" "Å"
# combine with other characters
'Injeksjons\u00E6ske'
[1] "Injeksjonsæske"