1
library(stringr)
I am trying to extract only the uppercase words from a string.
teste <- "Isto é um Teste para ver se Eu consigo capturar APENAS as Palavras TOTALMENTE Maiusculas"
teste
[1] "Isto é um Teste para ver se Eu consigo capturar APENAS as Palavras TOTALMENTE Maiusculas"
Use the str_extract_all()
and pass a REGEX that seeks to capture only words "\w" that are branded as uppercase "[:upper:]"
The function until it locates the correct words, but divides them every 2 letters.
str_extract_all(teste, "\\w[:upper:]")
[[1]]
[1] "AP" "EN" "AS" "TO" "TA" "LM" "EN" "TE"
Why?
Which way is right?