1
我有一個名爲cars
串如下:正則表達式到直到托架關閉的第一次出現
cars
[1] "Only one car(52;model-14557) had a good engine(workable condition), others engine were damaged beyond repair"
[2] "Other car(21, model-155) looked in good condition but car (36, model-8878) looked to be in terrible condition."
我需要從字符串中提取以下部分:
car(52;model-14557)
car(21, model-155)
car (36, model-8878)
我嘗試使用下面的一塊可以提取它:
stringr::str_extract_all(cars, "(.car\\s{0,5}\\(([^]]+)\\))")
這給了我以下輸出:
[[1]]
[1] " car(52;model-14557) had a good engine(workable condition)"
[[2]]
[1] " car(21, model-155) looked in good condition but car (36, model-8878)"
有沒有一種方法可以提取帶有關聯號碼和型號的單詞汽車?
正是我想要的。謝謝 – SBista