I want to extract the name from the following input which is of the form as shown in brackets
# Example of the input in brackets('name":"Tale")
name<- c('name":"Tale"','name":"List"')
I want to extract the names between the quotes as shown below. Any suggestions?
name
Tale
List
We could use stri_extract_last_words
library(stringi)
library(data.table)
setDT(list(name=stri_extract_last_words(name)))[]
# name
#1: Tale
#2: List
Convert the vector to a single column data.frame
, and then just use gsub
to remove the name":
and "
from the string.
Example:
transform(data.frame(name), name = gsub("name\":|\"", "", name))
## name
## 1 Tale
## 2 List
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.