Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting text after "?"

I have a string

x <- "Name of the Student? Michael Sneider"

I want to extract "Michael Sneider" out of it.

I have used:

str_extract_all(x,"[a-z]+")
str_extract_all(data,"\\?[a-z]+")

But can't extract the name.

like image 299
Bitanshu Das Avatar asked Mar 26 '26 19:03

Bitanshu Das


2 Answers

I think this should help

substr(x, str_locate(x, "?")+1, nchar(x))
like image 71
Saksham Avatar answered Mar 29 '26 07:03

Saksham


Try this:

sub('.*\\?(.*)','\\1',x)
like image 29
Shenglin Chen Avatar answered Mar 29 '26 09:03

Shenglin Chen