Reputation: 21312
I have the following string:
What is **Sympathy.**
I'm attempting to create a regex statement that will find the string "Sympathy." between the double asterisk, including the double asterisk. However, I can't even figure out how to find the string between first.
This is what I've tried:
(?<=\\*\\*)(.*)(?=\\*\\*)
Any assistance would be appreciated.
Upvotes: 4
Views: 4416
Reputation: 1
\*{2}(.*?)\*{2}
\*{2} -- matches double asterisks
(.*?) -- captures anything, with "?" specifying non-greedy
Regex was tested here: https://regex101.com/
Upvotes: 0
Reputation: 26434
I tested this out and it worked
\*{2}(.*?)\*{2}
Breakdown
\*{2}
- matches the character * literally (exactly 2 times)
1st Capturing group (.*?)
- The quantifier will match it between 0 and unlimited times
\*{2}
- matches the character * literally (exactly 2 times)
https://regex101.com/r/uQ0gJ1/1
Upvotes: 10