title: PCRE PHP Concrete example of the usage and utility of the "S" (Extra analysis of pattern) modifier?
body: <p>the PHP manual states the following about the PCRE's "S" (Extra analysis of pattern) modifier on <a href="http://php.net/manual/en/reference.pcre.pattern.modifiers.php" rel="noreferrer">http://php.net/manual/en/reference.pcre.pattern.modifiers.php</a></p>
  
  <blockquote>
    <p>S </p>
    
    <p>When a pattern is going to be used several times, it is worth
    spending more time analyzing it in order to speed up the time taken
    for matching. If this modifier is set, then this extra analysis is
    performed. At present, studying a pattern is useful only for
    non-anchored patterns that do not have a single fixed starting
    character.</p>
  </blockquote>
  
  <p>So its usage is related to patterns which should be used several times, without anchors inside of them (such as <code>^</code>, <code>$</code>) or a fixed starting char sequence, e.g. in a pattern like <code>'/^abc/'</code>.</p>
  
  <p>But there aren't any specific details on where e.g. apply this modifier and how it actually works. </p>
  
  <p>Does it apply only for the PHP thread of the current executing script and after the script is executed the "cached" analysis of the pattern is lost? Or does the engine store the analysis of the pattern in a global cache which is then made available to several PHP threads that use PCRE with the pattern marked with this modifier?</p>
  
  <p>Also, from the PCRE introduction: <a href="http://php.net/manual/en/intro.pcre.php" rel="noreferrer">http://php.net/manual/en/intro.pcre.php</a></p>
  
  <blockquote>
    <p>Note: This extension maintains a global per-thread cache of compiled
    regular expressions (up to 4096)</p>
  </blockquote>
  
  <p>If the "S" modifier is used per-thread only, how does it differs from the PCRE cache of compiled regexps? I guess additional information is stored, something like MySQL does when it indexes the rows in a table (of course in the case of PCRE, this additional information is stored in memory).</p>
  
  <p>Last, but not the least, have someone experienced a real use case where he/she had used this modifier and did you notice an improvement and appreciate its benefits?</p>
  
  <p>Thanks for the attention.</p>