How to detect and replace a regular expression match in the R programming language. More details: [ Ссылка ]
R code of this video:
my_string <- "xxxx10yyyy" # Create example character string
my_string # Print example character string
my_expression <- "[0-9]+" # Create example regular expression
my_expression # Print example regular expression
regexpr(my_expression, my_string) # Locate regular expression
regmatches(my_string, # Return regular expression
regexpr(my_expression, my_string))
install.packages("stringr") # Install & load stringr
library("stringr")
str_locate(my_string, my_expression) # Locate regular expression
str_extract(my_string, my_expression) # Return regular expression
Follow me on Social Media:
Facebook: [ Ссылка ]
LinkedIn: [ Ссылка ]
Twitter: [ Ссылка ]
![](https://s2.save4k.ru/pic/xMcmPGHhjeI/maxresdefault.jpg)