Reputation: 606
I keep seeing solutions for Regexes that find lines/words with a start and end pattern but the difference is their patterns are different.
My dilemma is finding lines that have the same ending and start pattern.
Example:
** Hello, My name is
Name: enter**
That would result to one match. However when I do
Example:
**Hello, My name is
Name: enter**
**Designation is:
Field work**
The match result should be two, but catches three, which are:
**Hello, My name is
Name: enter**
And:
**
**
And:
**Designation is:
Field work**
I'm using this Regex:
"^##.*##"
Someone said it is not possible using Regex, is this true?
Upvotes: 1
Views: 382
Reputation: 3299
Try this: /\*\*(.+?)\*\*/s
\*\* #match the first **
(.+?) # match any char btween ** and ** and group
\*\* #match the last **
s #single line modifier.
Upvotes: 1
Reputation: 67968
(\*\*[\s\S]*?\*\*)
Try this.See demo.
https://regex101.com/r/tX2bH4/12
Upvotes: 0