查找具有相同开始和结束模式的多行的正则表达式

RegEx that finds multiple lines that have same starting and ending pattern

我一直看到找到 lines/words 具有开始和结束模式的正则表达式的解决方案,但不同之处在于它们的模式不同。

我的难题是找到具有相同结束和开始模式的行。

示例:

** Hello, My name is
Name: enter**

这将导致一场比赛。但是当我这样做时

示例:

 **Hello, My name is
 Name: enter**
 **Designation is:
 Field work**

匹配结果应该是两个,却捕获了三个,分别是:

 **Hello, My name is
 Name: enter**

并且:

             **
**

并且:

**Designation is:
Field work**

我正在使用这个正则表达式:

"^##.*##"

有人说不能使用正则表达式,这是真的吗?

(\*\*[\s\S]*?\*\*)

尝试 this.See 演示。

https://regex101.com/r/tX2bH4/12

试试下面的正则表达式

(\*\*(.*?)\*\*\*)

试试这个: /\*\*(.+?)\*\*/s

\*\* #match the first ** 
(.+?) # match any char btween ** and **  and group 
\*\*  #match the last ** 
s  #single line modifier.

Live demo

VB demo