我有一个文字假设
1) "Project:ABC is located near CBA, being too far from city "
2) "P r o j e c t : PQR is located near RQP, highlights some greenary"
我想在单词“ project ”和“ , ”之间提取文本,以便我的输出是ABC is located near CBA
来自text1的“ PQR is located near RQP
”和来自text2的“” ,因为我使用了正则表达式
x="Project:ABC is located near CBA, being too far from city "
sub(".*Project: *(.*?) *, .*", "\\1", x)
O\P
ABC is located near CBA
但是对于text2)它没有给出正确的输出,所以我如何包含 OR 条件以便满足我的两个条件。任何建议都会有所帮助。谢谢