我有一个看起来像这样的字符串:
First dog?</strong><br>Text, which looks lke this. More text.</p> What about the dog?</p> Blah blah. What about the dog?
我尝试仅提取Text, which looks like this. More text.
或本质上提取What about the dog?
的第一个实例之前的所有文本。
我使用了此正则表达式,但它也捕获了What about the dog?
的第二个实例之前的所有文本。
str_extract(test, "(?<=First dog\\?</strong><br>)[:alpha:].+(?=What about the dog)")
如何创建正则表达式以仅捕获What about the dog?
的第一个实例之前的文本分组。