正则表达式:在字符串中的两个标签之间提取子字符串 [英] Regex: To pull out a sub-string between two tags in a string
本文介绍了正则表达式:在字符串中的两个标签之间提取子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个以下格式的文件:
I have a file in the following format:
Data Data
Data
[Start]
Data I want
[End]
Data
我想使用Regex从[Start]
和[End]
标记之间抓取Data I want
.谁能告诉我该怎么做?
I'd like to grab the Data I want
from between the [Start]
and [End]
tags using a Regex. Can anyone show me how this might be done?
推荐答案
\[start\]\s*(((?!\[start\]|\[end\]).)+)\s*\[end\]
这也有望删除[start]
和[end]
标记.
这篇关于正则表达式:在字符串中的两个标签之间提取子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文