Home > Blockchain >  how to extract the 2nd number in a string
how to extract the 2nd number in a string

Time:09-11

I want to extract only the second number (in order) from a string.

string = vancomycin 1G IV 3 times a day over 1 hour.

desired output = 3

CodePudding user response:

A posssible solution, but not the prettiest one

str_extract_all(string, "\\d ")[[1]][2]
  • Related