Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maxwell Troy Milton King is right, but since his answer is a bit short, I'll post this as well and provide some examples to illustrate.</p> <p>First, the <code>.</code> meta character by default does NOT match line breaks. This is true for many regex implementations, including PHP's flavour. That said, take the text:</p> <pre><code>$text = "Line 1\nLine 2\nLine 3"; </code></pre> <p>and the regex</p> <pre><code>'/.*/' </code></pre> <p>then the regex will only match <code>Line 1</code>. See for yourself:</p> <pre><code>preg_match('/.*/', $text, $match); echo $match[0]; // echos: 'Line 1' </code></pre> <p>since the <code>.*</code> "stops matching" at the <code>\n</code> (new line char). If you want to let it match line breaks as well, append the s-modifier (aka DOT-ALL modifier) at the end of your regex:</p> <pre><code>preg_match('/.*/s', $text, $match); echo $match[0]; // echos: 'Line 1\nLine 2\nLine 3' </code></pre> <p>Now about the m-modifier (multi-line): that will let the <code>^</code> match not only the start of the input string, but also the start of each line. The same with <code>$</code>: it will let the <code>$</code> match not only the end of the input string, but also the end of each line.</p> <p>An example:</p> <pre><code>$text = "Line 1\nLine 2\nLine 3"; preg_match_all('/[0-9]$/', $text, $matches); print_r($matches); </code></pre> <p>which will match only the 3 (at the end of the input). But:</p> <p>but enabling the m-modifier:</p> <pre><code>$text = "Line 1\nLine 2\nLine 3"; preg_match_all('/[0-9]$/m', $text, $matches); print_r($matches); </code></pre> <p>all (single) digits at the end of each line ('1', '2' and '3') are matched.</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.
    3. VO
      singulars
      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