我有一個很多文字的列,我只想保留之間的文字[start section id="20107"]
和[end section id="20107"]
其餘不重要。R我如何保留兩個indetifiers之間的字符串
這裏的原始數據
[start section id="20106"]
California, Death Valley
[end section id="20106"]
[start section id="20107"]
1. Apple
2. Orange
3. Bannana
4. Kiwi
5. Grapes
6. Strawberry
[end section id="20107"]
[start section id="20108"]
Jose has worked on these farms , currently he is in Florida picking tomatos
[end section id="20108"]
我所試圖做的就是保持起始區段編號之間的文本= 「20107」 和結束部分ID = 「20107」
[start section id="20107"]
1. Apple
2. Orange
3. Bannana
4. Kiwi
5. Grapes
6. Strawberry
[end section id="20107"]
任何幫助在這個話題非常感謝。
你嘗試過自己嗎?以下是如何創建一個[可重現的例子](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Heroka
@Heroka,我試過'testdf = filter( org_df,grepl('[start section id =「20107」] | [end section id =「20107」]',col1))',我沒有得到正確的結果,它顯示了原始列,並沒有擺脫這些開始和結束條件之外的文本 –
請提供一些示例數據並添加您嘗試的答案。並且grepl會爲整個字符串內的匹配返回一串布爾值。你可能需要gsub。 – Heroka