我有一个这样的表示例
No, Memo
1, Date: 2020/10/22 City: UA Note: True mastery of any skill takes a lifetime.
2, Date: 2022/11/01 City: CH Note: Sweat is the lubricant of success.
3, Date: 2022y11m1d City: UA Note: Every noble work is at first impossible.
4, Date: 2022y2m15d City: AA Note: Live beautifully, dream passionately, love completely.
我想提取Date:
,City:
和Note:
之后的字符串。例如,在NO。1,我需要提取Date:
和City:
之间的“2020/10/22”,City:
和Note:
之间的“UA”,以及Note:
之后的“真正掌握任何技能都需要一辈子”。
所需输出,如:
No Date City Note
1 2020/10/22 UA True mastery of any skill takes a lifetime.
2 2022/11/01 CH Sweat is the lubricant of success.
3 2022y11m1d UA Every noble work is at first impossible.
4 2022y2m15d AA Live beautifully, dream passionately, love completely.
有人知道答案吗?任何帮助都是很好的。谢谢。
1条答案
按热度按时间raogr8fs1#
我使用regex和
stringr
和dplyr
的解决方案正则表达式匹配使用正向lookahead和loohbehind指定的组之间的所有内容。