I have the following string in R:
str <- "number_123 some text number_4"
Now, I want to extract the numbers 123 and 4 into vector of numerics. However, I was not able to come up with a regular expression to identify the numbers 123 and 4. The only identifier in this problem is "number_". I would like to extract the subsequent number which can be anything from 1 to 3 figures.
I found some regular expressions for some similar issues here. However I was not able to change it in such a way such that it fits my problem.
Thanks for your help!
Edit: sorry being not more precise. The actual string looks like the following:
str <- '\"number_123\"somtext 123 some more text\"number_1\" text'
As before I would like to extract the numbers following the substring \"number. Unfortunately, all your solutions did not work. I got the following warning message:
NAs introduced by coercion