I am trying keep only that part of the string left of "keyword"
. Anything on the right of "keyword"
should be removed. beg2char
seems like the best choice but its not doing what I thought it would do.
Please advise:
x <-"/index.php/front/yellow/searchHeading/heading/926/h_name/Architects/keyword/A//"
beg2char(x,"keyword")
# [1] "/in"
If we want to keep the "keyword"
in the output, then set include = TRUE
:
library(qdap)
x <-"/index.php/front/yellow/searchHeading/heading/926/h_name/Architects/keyword/A//"
beg2char(x, "keyword", include = TRUE)
# [1] "/index.php/front/yellow/searchHeading/heading/926/h_name/Architects/keyword"
If we want to exclude "keyword"
, then we would do as you did, which doesn't work, because letter "d"
is part of the "keyword"
. Looks like a bug to me, submitted an issue at GitHub:qdap.
But this works:
beg2char(x, "k")
# [1] "/index.php/front/yellow/searchHeading/heading/926/h_name/Architects/"