From 84fa3b1e28076d22bf0054d8306eaaf72545ebae Mon Sep 17 00:00:00 2001 From: Olivia <92395083+OliviaLorente-Casalini@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:35:25 +0200 Subject: [PATCH] Add files via upload --- stringr.html | 74 +++++++++++++++++++++++++++------------------------- stringr.md | 4 +++ stringr.qmd | 4 +++ 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/stringr.html b/stringr.html index 4e058e5..4bbada4 100644 --- a/stringr.html +++ b/stringr.html @@ -384,41 +384,45 @@

str_match()

#> [7,] NA #> [8,] "son" #> [9,] NA -str_match(versos, "(son) (buenos|mejores)") -#> [,1] [,2] [,3] -#> [1,] NA NA NA -#> [2,] "son buenos" "son" "buenos" -#> [3,] NA NA NA -#> [4,] "son mejores" "son" "mejores" -#> [5,] NA NA NA -#> [6,] NA NA NA -#> [7,] NA NA NA -#> [8,] NA NA NA -#> [9,] NA NA NA -str_match(versos, "(que|son) ([^ ]+)") -#> [,1] [,2] [,3] -#> [1,] "que luchan" "que" "luchan" -#> [2,] "son buenos" "son" "buenos" -#> [3,] "que luchan" "que" "luchan" -#> [4,] "son mejores" "son" "mejores" -#> [5,] NA NA NA -#> [6,] "son muy" "son" "muy" -#> [7,] "que luchan" "que" "luchan" -#> [8,] "son los" "son" "los" -#> [9,] NA NA NA -str_match(estrofa, "(que|son) ([^ ]+)") -#> [,1] [,2] [,3] -#> [1,] "que luchan" "que" "luchan" -str_match_all(estrofa, "(que|son) ([^ ]+)") -#> [[1]] -#> [,1] [,2] [,3] -#> [1,] "que luchan" "que" "luchan" -#> [2,] "son buenos." "son" "buenos." -#> [3,] "que luchan" "que" "luchan" -#> [4,] "son mejores." "son" "mejores." -#> [5,] "son muy" "son" "muy" -#> [6,] "que luchan" "que" "luchan" -#> [7,] "son los" "son" "los" + +str_match(versos, "(son) (buenos|mejores)") +#> [,1] [,2] [,3] +#> [1,] NA NA NA +#> [2,] "son buenos" "son" "buenos" +#> [3,] NA NA NA +#> [4,] "son mejores" "son" "mejores" +#> [5,] NA NA NA +#> [6,] NA NA NA +#> [7,] NA NA NA +#> [8,] NA NA NA +#> [9,] NA NA NA + +str_match(versos, "(que|son) ([^ ]+)") +#> [,1] [,2] [,3] +#> [1,] "que luchan" "que" "luchan" +#> [2,] "son buenos" "son" "buenos" +#> [3,] "que luchan" "que" "luchan" +#> [4,] "son mejores" "son" "mejores" +#> [5,] NA NA NA +#> [6,] "son muy" "son" "muy" +#> [7,] "que luchan" "que" "luchan" +#> [8,] "son los" "son" "los" +#> [9,] NA NA NA + +str_match(estrofa, "(que|son) ([^ ]+)") +#> [,1] [,2] [,3] +#> [1,] "que luchan" "que" "luchan" + +str_match_all(estrofa, "(que|son) ([^ ]+)") +#> [[1]] +#> [,1] [,2] [,3] +#> [1,] "que luchan" "que" "luchan" +#> [2,] "son buenos." "son" "buenos." +#> [3,] "que luchan" "que" "luchan" +#> [4,] "son mejores." "son" "mejores." +#> [5,] "son muy" "son" "muy" +#> [6,] "que luchan" "que" "luchan" +#> [7,] "son los" "son" "los" diff --git a/stringr.md b/stringr.md index 375fa53..1f23d13 100644 --- a/stringr.md +++ b/stringr.md @@ -320,6 +320,7 @@ str_match(versos, "son") #> [7,] NA #> [8,] "son" #> [9,] NA + str_match(versos, "(son) (buenos|mejores)") #> [,1] [,2] [,3] #> [1,] NA NA NA @@ -331,6 +332,7 @@ str_match(versos, "(son) (buenos|mejores)") #> [7,] NA NA NA #> [8,] NA NA NA #> [9,] NA NA NA + str_match(versos, "(que|son) ([^ ]+)") #> [,1] [,2] [,3] #> [1,] "que luchan" "que" "luchan" @@ -342,9 +344,11 @@ str_match(versos, "(que|son) ([^ ]+)") #> [7,] "que luchan" "que" "luchan" #> [8,] "son los" "son" "los" #> [9,] NA NA NA + str_match(estrofa, "(que|son) ([^ ]+)") #> [,1] [,2] [,3] #> [1,] "que luchan" "que" "luchan" + str_match_all(estrofa, "(que|son) ([^ ]+)") #> [[1]] #> [,1] [,2] [,3] diff --git a/stringr.qmd b/stringr.qmd index 1b9adbd..5505f13 100644 --- a/stringr.qmd +++ b/stringr.qmd @@ -196,9 +196,13 @@ La función `str_match(texto, patrón)` realiza lo mismo que la función `str_ex ```{r str_match()} str_match(versos, "son") + str_match(versos, "(son) (buenos|mejores)") + str_match(versos, "(que|son) ([^ ]+)") + str_match(estrofa, "(que|son) ([^ ]+)") + str_match_all(estrofa, "(que|son) ([^ ]+)") ```