Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>polygenelubricants already explained why your regex <em>failed</em>. The reason it <em>hangs</em> is that you're running into <a href="http://www.regular-expressions.info/catastrophic.html" rel="nofollow noreferrer">catastrophic backtracking</a>. Your regex has many parts that can match the same text in a lot of different ways. If the overall match fails, the regex engine will try all possible permutations until it either exhausts them all or aborts with a Stack Overflow. </p> <p>E. g. in <code>To:\W+(?&lt;custAddr&gt;.*?)\W+</code> the <code>.*?</code> will gladly match the same characters as <code>\W</code>, and since you're using <code>Singleline</code>, the <code>.*?</code> will also cross over into the <code>No:...</code> part of the input text and further and further. In your example, I tested in RegexBuddy what happens if you add the "N" after "Cust" - the regex engine aborts after 1,000,000 steps.</p> <p>To avoid this, you need to make the regex more specific, or (this might be the better option in this case) keep the regex engine from backtracking by enclosing parts that have already matched in "<a href="http://www.regular-expressions.info/atomic.html" rel="nofollow noreferrer">atomic groups</a>":</p> <pre><code>(?&gt;\W+INVOICE\W+) (?&gt;(?&lt;shopAddr&gt;.*?)\W+To:) (?&gt;\W+(?&lt;custAddr&gt;.*?)\W+No:) (?&gt;\W+(?&lt;invNo&gt;\d+).*?Date:) (?&gt;\W+(?&lt;invDate&gt;[0-9/\ :]+)\W+Ref:) (?&gt;\W+(?&lt;ref&gt;[\w\ ]*?)\W+Cust) </code></pre> <p>This allows the regex to fail much faster if the input and the regex happen not to fit together.</p>
    singulars
    1. This table or related slice is empty.
    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. 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.
 

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