Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am no expert at how regex engines actually work, but I know that some (all?) are greedy and will try to match as much as possible as early as possible. So suppose you have string <code>s</code> you are trying to match, which has no <code>'&lt;'</code> characters. It will first match the <code>[^&lt;]*</code> part of the regex, essentially matching everything from <code>s[0]</code> to <code>s[n-1]</code> (<code>s</code> is zero-indexed and doesn't have c-string subtleties, so this is the entire string). It will then fail on the next element in the pattern (the <code>'&lt;'</code> character). Next, it will backtrack to matching <code>[^&lt;]*</code> from <code>s[0]</code> to <code>s[n-2]</code>, attempt to match <code>'&lt;'</code>, and fail again. This will repeat until it matches a string of length 0 at position 0 (note <code>*</code> matches zero or more repetitions and this final case is zero repetitions). So thus it will determine that starting at position 0 cannot result in a successful match, so it will repeat the above, this time starting the range of matched characters at <code>s[1]</code>, only to fail again after exhausting all such ranges. It will then start at position 2 and so on, until it tries to match at after the last character. Then it will give up. </p> <p><strong>Edit:</strong> Your regex will essentially match any part of the string that ends in <code>&lt;?</code> and does not contain another <code>&lt;</code>, for instance in <code>&lt;&lt;?</code> it matches <code>&lt;?</code> and in <code>ba&lt;abc&lt;?def</code>, it matches <code>abc&lt;?</code>. Some of the other suggestions offered will behave differently. In particular, <code>^[^&lt;]*&lt;\?</code> will not match anything in these two examples. </p>
    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. 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