title: How to fix this regex (matching dictionary entries)
body: <p>I am working with a spanish dictionary that has definitions like the following:</p>
  
  <pre><code>l. a. c. Buitre, alimoche. adj. Persona alelada. (Cornago). GOICOECHEA. // 2. f. Persona torpe, despistada e irreflexiva. // 3. Estar mirando a los abantos. fr. fig. Ser despistado, soñador, no apercibirse de la realidad. Autol. RUIZ. // 4. f. esto es una prueba
  </code></pre>
  
  <p>Where the following rules apply:</p>
  
  <ul>
  <li>Each definition MAY contain one (and never more than one) of the following categories:
  <ul>
  <li><code>l. a. c.</code> </li>
  <li><code>f.</code> </li>
  <li><code>m.</code></li>
  </ul></li>
  <li>The category is always at the start of a definition</li>
  <li>The first definition starts from the begining, if there are more definitions, they start with <code>\\ n.</code> where 'n' is a number (could be more than one digit)</li>
  </ul>
  
  <p>For the example I gave, the following definitions should be parsed:</p>
  
  <ol>
  <li>(Category: <code>l.a.c.</code>) Buitre, alimoche. adj. Persona alelada. (Cornago). GOICOECHEA</li>
  <li>(Category: <code>f.</code>) Persona torpe, despistada e irreflexiva.</li>
  <li>(No category) Estar mirando a los abantos. fr. fig. Ser despistado, soñador, no apercibirse de la realidad. Autol. RUIZ.</li>
  <li>(Category: <code>f.</code>) esto es una prueba</li>
  </ol>
  
  <p>I am trying to make a regex to capture every definition (that is 0 or 1 category + meaning). This is what I have</p>
  
  <pre><code>(?:(m\.|l\. a\. c\.|f\.) )?(.*?) (?:$|(?:\/\/ \d+. (?:(m\.|l\. a\. c\.|f\.) )?(.*?))+)
  </code></pre>
  
  <p>I am testing it <a href="https://regex101.com/r/gH2uD9/2" rel="nofollow">here</a> This is how I wrote it:</p>
  
  <pre><code>(?:
      (m\.|l\. a\. c\.|f\.)  &lt;-- First: unnamed group containing the named group 
                                        for the category  and one space
  )?
  (.*?)                      &lt;-- Named group for the meaning
  (?:                        &lt;-- Unnamed group for end of line OR another definition
     $                       &lt;--- (end of line)
     |                       &lt;--- (OR)
     (?:\/\/ \d+.            &lt;--- (Definition separator &amp; number)
         (?:(m\.|l\. a\. c\.|f\.) )?(.*?) &lt;-- Another definition
     )+                                   &lt;-- There may be more than one definition, so we add '+'
  )
  </code></pre>
  
  <p>I have serveral problems:</p>
  
  <ul>
  <li>I am not sure why it does not work. It seems like the last capture group <code>(.*?)</code> is not expanding until the next <code>\\</code>. How can I fix it?</li>
  <li>The group <code>(m\.|l\. a\. c\.|f\.)</code> should be larger (there are more categories) How can I avoid repeating it?</li>
  <li>There are some repetition in the regex string that I gave, how can I avoid that?</li>
  </ul>
  
  <p>This is my first non-trivial regex example, so any other comentaries about style, or improve in general are welcome.</p>
  
  <p>My main question is <strong><em>why is my regex not working.</em></strong> (This is just to clarify...)</p>