I want to capture all the text that is between 2 stars (*). It should be between exactly 2 stars on each side. Eg. If the text is
This is **heading1** and this is ***heading2**** and this is **heading3** and this is **heading4***.
I want the regex output to be [‘heading1’, ‘heading3’] since this is the only text between exactly 2 stars (*) on both sides.
I wrote the following code but its giving incorrect output.
pattern = r'**(.*?)**'
matches = re.findall(pattern, text)
I want to match texts exactly between 2 stars each. How can I do that?