python removing references from a scientific paper
<p>NOTE: I am inexperienced with regular expressions.</p>

<p>I want to be able to convert scientific articles into iTunes tracks. To do this I copy and paste the text in txt files and convert them to spoken tracks. However when I do this the references are included and the computer's voice reads them aloud e.g. "(Smith J. et al. 2016)" and this is annoying as I'd like it to skip anything in brackets containing a reference.
Hence I want to make a python script that removes all of these references from the txt file before converting it to a spoken track.
I reckon that I could do this with something like the following code:</p>

<pre><code>start_ref=find("(")
finish_ref=find(")", start_ref)
# then remove all pieces of the string between each start and finish 
</code></pre>

<p>But this is not accurate enough. Instead I would like to somehow use regular expressions.</p>

<p>can someone show me some example code as to how I would iterative remove the references from the following text (while accounting for different referencing styles e.g. Harvard vs APA etc.):</p>

<blockquote>
  <p>"This method has been shown to outperform previously discussed methods
  (Smith, J. et al., 2014) and while it has its draw-backs, it is clear
  that the benefits outweigh the disadvantages (Jones, A. &amp; Karver, B.,
  2009, Lubber, H. et al., 2013)."</p>
</blockquote>

<p>Can anyone provide some sample code?</p>

<p>something like</p>

<pre><code> import re
 text = ...
 re.sub(r'\((?:[\w \.&amp;]+\, )+[0-9]{4}\)', text)
</code></pre>

<p>seems to do it.
You can use <a href="https://www.debuggex.com/" rel="nofollow">Debuggex</a> to train yourself in regex.</p>

python string