Extracting value and assigning with str_match

yy = c("I am having a Full Name Sunil Raperia 4,50,000.00")
Using the below function gives me Sunil Raperia,

stringr::str_match(yy, "Name (.*) ")[,2]
As per the requirement it should be Sunil Raperia 4,50,000.00 Is there anything which I am missing in the function?

There is a space before the closing quote of the regex, so the search returns the longest string that ends in a space. Try removing that space.

> stringr::str_match(yy, "Name (.*)")[,2]
[1] "Sunil Raperia 4,50,000.00"
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.