<p>First thing, the &quot;^&quot; is wrong - as that would only match text at the begining of the line. The * after the g also does not mean &quot;anything&quot; - but &quot;any number of g&quot;.</p>
<p>You could try with
re_res=re.findall(&quot;https://arxiv.org/[^\s\)\]]*[0-9]&quot;</p>
<p>It is not fool proof but should cover most cases.</p>
<p>find <code>https://arxiv.org/</code>
that is followed by anything (<code>*</code>) not (<code>[^...]</code> space <code>\s</code> closing round or square brackets(<code>\)\]</code>) (together <code>[^\\s\\\)\\]]*</code>) but ends whith a number (<code>[0-9]</code>).</p>
Matching arxiv regular expression in Python
<p>I have paragraph and from it I want to extract the arxiv dois. For example, this is the given paragraph:</p>
<pre><code>&quot;Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

Further information can be referred to this [arXiv article]`(https://arxiv.org/abs/2109.05857).`&quot;
</code></pre>
<p>The output should be: <code>https://arxiv.org/abs/2109.05857</code>.
The start of arxiv doi will always be &quot;https://arxiv.org&quot; or &quot;arxiv.org&quot; and the appeded string could be anything.</p>
<p>I tried <code>exp = re.findall(&quot;^https://arxiv.org*&quot;, str)</code> but it doesn't work.</p>
<p>Any help will be appreciating.</p>