Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a single character to my .NET RegEx causes it to hang
    primarykey
    data
    text
    <p>Here is the input data:</p> <pre><code> *** INVOICE *** THE BIKE SHOP 1 NEW ROAD, TOWNVILLE, SOMEWHERE, UK, AB1 2CD TEL 01234-567890 To: COUNTER SALE No: 243529 Page: 1 Date: 04/06/10 12:00 Ref: Aiden Cust No: 010000 </code></pre> <p>Here is a regex that works (Options: singleline, ignorewhitespace, compiled) - it matches immediately and the groups are properly populated:</p> <pre><code>\W+INVOICE\W+ (?&lt;shopAddr&gt;.*?)\W+ To:\W+(?&lt;custAddr&gt;.*?)\W+ No:\W+(?&lt;invNo&gt;\d+).*? Date:\W+(?&lt;invDate&gt;[0-9/ :]+)\W+ Ref:\W+(?&lt;ref&gt;[\w ]*?)\W+ Cust </code></pre> <p>As soon as I add the 'N' out of Cust No into the rex, parsing the input hangs forever:</p> <pre><code>\W+INVOICE\W+ (?&lt;shopAddr&gt;.*?)\W+ To:\W+(?&lt;custAddr&gt;.*?)\W+ No:\W+(?&lt;invNo&gt;\d+).*? Date:\W+(?&lt;invDate&gt;[0-9/ :]+)\W+ Ref:\W+(?&lt;ref&gt;[\w ]*?)\W+ Cust N </code></pre> <p>If I add something like "any character" :</p> <pre><code>\W+INVOICE\W+ (?&lt;shopAddr&gt;.*?)\W+ To:\W+(?&lt;custAddr&gt;.*?)\W+ No:\W+(?&lt;invNo&gt;\d+).*? Date:\W+(?&lt;invDate&gt;[0-9/ :]+)\W+ Ref:\W+(?&lt;ref&gt;[\w ]*?)\W+ Cust . </code></pre> <p>It works, but as soon as I add a fixed character, the rex hangs again:</p> <pre><code>\W+INVOICE\W+ (?&lt;shopAddr&gt;.*?)\W+ To:\W+(?&lt;custAddr&gt;.*?)\W+ No:\W+(?&lt;invNo&gt;\d+).*? Date:\W+(?&lt;invDate&gt;[0-9/ :]+)\W+ Ref:\W+(?&lt;ref&gt;[\w ]*?)\W+ Cust ..: </code></pre> <p>Can anyone advise why adding something so trivial would cause it to fall over? Can I enable some kind of tracing to watch the matching activity to see if it is getting stuck in a catastrophic backtrack?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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