Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think version 5.10 and beyond, it only affects capture buffers if there was a match.<br> The interesting thing in your example, is that with <code>$string =~ s/^(\t*)([^\t]+)/$2/gi;</code><br> it didin't reset the capture buffers. That appears to be because of a preamble that estimates<br> if the match should be tried. In this case, <code>([^\t]+)</code> consumed the entire string in the first<br> match, so a <code>string too short</code> occured and the buffers were never reset. </p> <p>I can't test it but <code>$string =~ s/^(\t*)([^\t])//gi</code> should give the same warning.<br> <code>if ( s///g ) {}</code> and testing of capture buffers in this case is not certain to contain<br> anything. This was the case in version 5.8. Even in later versions its really just a debug feature. </p> <p><strong>Edit</strong> @theracoon - on your comment: <em>"I'm reasonably certain that ([^\t]+) did not actually consume the entire string. The output definitely does not reflect that."</em> </p> <p>This is a proof that your regex consumed the entire string on the first match, Pass 1.<br> There is nothing left to match on the second pass. That is the way the /g modifier works.<br> It tries to match the entire regex again, in the postion in the string where the last match left off. </p> <pre><code>use re 'debug'; $string = "\t\t\tEntry"; $string =~ s/^(\t*)([^\t]+)/$2/gi; print "'$string'\n"; </code></pre> <p>Pass 1 ..<br> Matching REx <code>"^(\t*)([^\t]+)"</code> against <code>"%t%t%tEntry"</code><br> 8 &lt;<code>%t%t%tEntry</code>> &lt;><br> Match successful! </p> <p>Pass 2 ..<br> Matching REx <code>"^(\t*)([^\t]+)"</code> against <code>""</code> (Nope, nothing left to match)<br> String too short [regexec_flags]...<br> Match failed<br> 'Entry' </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. 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