If the input L
is as given reproducibly in the Note at the end then use sub
to replace MG or ML and everything after with a space followed by MG or ML and then read it using read.table
:
s <- sub("(M[GL]).*", " \1", L)
read.table(text = s, as.is = TRUE, skip = 1, col.names = c("Name", "Strength", "Unit"))
giving:
Name Strength Unit
1 FALCAN 150.0 MG
2 AUGMENTIN 500.0 MG
3 PRE-13 0.5 ML
4 NS.9%w/v 250.0 ML
Note: The input L
used is:
L <- c("Medicine name", " FALCAN 150 MG tab", " AUGMENTIN 500MG tab",
" PRE-13 0.5 ML PFS inj", " NS.9%w/v 250 ML, Glass Bottle")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…