Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Josh mentioned, the <code>+</code> qualifier shouldn't be used with <code>{m,n}</code>. <code>+</code> matches one or more of the re while <code>{m,n}</code> matches m to n repetitions greedily. (See: <a href="http://docs.python.org/2/library/re.html#regular-expression-syntax" rel="nofollow">re syntax</a>).</p> <p>He also made a good point to use <a href="http://docs.python.org/2/library/re.html#re.VERBOSE" rel="nofollow">re.VERBOSE</a> to with help readability for your regex.</p> <p>EDIT: (thanks @eyguem for pointing this out) I may be wrong but your <code>[ |.]</code> is an attempt to match a space and a period? If so, you don't need the <code>|</code> <strike>and it may be good habit to escape re special characters such as the <code>.</code>. (i.e. <code>[ \.]</code>).</strike></p> <p>If you know the string between season/episode and quality are alphabets, spaces, or periods you can use something like this (EDIT: if there are non-alphabet characters like '-', '+', etc., you'll need to add them into the character set):</p> <pre><code> tv = re.findall(r"""(.*) # Title [ .] S(\d{1,2}) # Season E(\d{1,2}) # Episode [ .a-zA-Z]* # Space, period, or words like PROPER/Buried (\d{3,4}p)? # Quality """, name, re.VERBOSE) </code></pre> <p>Likewise, you can do this for the movie part:</p> <pre><code>movie = re.findall(r"""(.*?[ .]\d{4}) # Title including year [ .a-zA-Z]* # Space, period, or words (\d{3,4}p)? # Quality """, name, re.VERBOSE) </code></pre> <p>This is the output:</p> <pre><code>---------- TV ---------- Show: The Newsroom 2012 Season: 2 Episode: 6 Quality: 720p ---------- TV ---------- Show: Breaking Bad Season: 5 Episode: 10 Quality: nonHD ---------- TV ---------- Show: Breaking Bad Season: 5 Episode: 10 Quality: 720p ---------- TV ---------- Show: Dexter Season: 8 Episode: 8 Quality: nonHD ---------- TV ---------- Show: Dexter Season: 8 Episode: 7 Quality: 1080p ---------- TV ---------- Show: Dexter Season: 8 Episode: 7 Quality: 720p --------- MOVIE -------- Title: The Great Gatsby 2013 Quality: 1080p --------- MOVIE -------- Title: The Forbidden Girl 2013 Quality: nonHD --------- MOVIE -------- Title: Pain &amp; Gain 2013 Quality: 720p ---------- TV ---------- Show: Band of Brothers Season: 1 Episode: 2 Quality: nonHD ---------- TV ---------- Show: Dexter Season: 8 Episode: 6 Quality: 720p ---------- TV ---------- Show: Dexter Season: 8 Episode: 6 Quality: 720p </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload