What regular expression selects a string between two "*" characters
<p>I want to select text between two * characters in a file and am having trouble forming the regular expression to do so.</p>

<p>For example with a file like the following:</p>

<pre><code>* Apple
Are good

* Banana 
Are great

* Cauliflower 
Are bad
</code></pre>

<p>It would select 3 different groups</p>

<p>Apple
Are good</p>

<p>Banana 
Are great</p>

<p>and </p>

<p>Cauliflower 
Are bad</p>

<p>I believe I need to use ^ and $ for this but my selector: <code>^\*$\*</code></p>

<p>is not working.</p>

<p>Regular expressions aren't even necessary here. Just use <code>str.split</code> and <code>str.strip</code>:</p>

<pre><code>&gt;&gt;&gt; f = '''* Apple
... Are good
...
... * Banana
... Are great
...
... * Cauliflower
... Are bad'''
&gt;&gt;&gt; for line in f.split('*'):
...     if line.strip():
...             print('start')
...             print(line.strip())
...             print('end')
...
start
Apple
Are good
end
start
Banana
Are great
end
start
Cauliflower
Are bad
end
</code></pre>

python regex