I was doing some RegEx exercises in a website that gives you some text with highlighted sections for you to match with a regular expression.
The following is just a snippet of the given text:
Durazzo</a>, <a href="/wiki/Ladislao_I_di_Napoli" title="Ladislao I di Napoli">Ladislao I di
Napoli</a> e <a href="/wiki/Giovanna_II_di_Napoli" title="Giovanna II di Napoli">Giovanna II di
Napoli</a>. L'ultima grande impresa degli angioini napoletani fu la spedizione militare di <a
href="/wiki/Ladislao_I_di_Napoli" title="Ladislao I di Napoli">Ladislao I di Napoli</a>, il primo
tentativo di riunificazione politica d'<a href="/wiki/Italia" title="Italia">Italia</a>, agli inizi
del <a href="/wiki/XV_secolo" title="XV secolo">XV secolo</a>.</p>
<h1><a href="http://www.repubblica.it/cronaca/2013/12/20/news
/serial_killer_in_fuga_cancellieri_in_parlamento-74089064/" target="_self" title="">Catturati i due
killer evasi</a></h1>
<h3><span class="editsection">[<a href="/w/index.php?title=Roma&action=edit&section=62"
title="Modifica la sezione Mobilità urbana">modifica</a>]</span> <span class="mw-headline"
id="Mobilit.C3.A0_urbana">Mobilità urbana</span></h3>
#l_footer a:hover, #l_footer_extended div.libero a:hover {
<h1><a href="http://temi.repubblica.it/guide-universita-2013-2014/">Università 2013-2014</a></h1>
</a>
al duca mio, e li occhi a lui drizzai.<br/>
</p>
And the goal was to match all the text between the header tags (including the tags themselves) ( ie.: <h?>...<\h?>
).
I know how to achieve the goal, however, when I accidently tried the regex <h[^]+
it seemed to select exactly the text that I needed and I do not understand how or why.
Any insights?
PS. For reference, this is the website and this particular example is 8/12.