[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] [doc-en] master: Fold the note on PCRE comments (#831)
From:       Kamil Tekiela via GitHub <noreply () php ! net>
Date:       2021-07-30 11:40:10
Message-ID: UhjQptAREhb9mWEDgSp0eNvjRVjFI3ESIiVWDV5H4 () main ! php ! net
[Download RAW message or body]

Author: Kamil Tekiela (kamil-tekiela)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2021-07-30T12:40:33+01:00

Commit: https://github.com/php/doc-en/commit/e059aa517b3c5cf79b98f182bf45607f12e9c560
Raw diff: https://github.com/php/doc-en/commit/e059aa517b3c5cf79b98f182bf45607f12e9c560.diff

Fold the note on PCRE comments (#831)

Changed paths:
  M  reference/pcre/pattern.syntax.xml


Diff:

diff --git a/reference/pcre/pattern.syntax.xml b/reference/pcre/pattern.syntax.xml
index 02f837ef6a..d3c2e1867d 100644
--- a/reference/pcre/pattern.syntax.xml
+++ b/reference/pcre/pattern.syntax.xml
@@ -2161,6 +2161,41 @@
    introduces a comment that continues up to the next newline character
    in the pattern.
   </para>
+  <para>
+   <example>
+    <title>Usage of comments in PCRE pattern</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+
+$subject = 'test';
+
+/* (?# can be used to add comments without enabling PCRE_EXTENDED */
+$match = preg_match('/te(?# this is a comment)st/', $subject);
+var_dump($match);
+
+/* Whitespace and # is treated as part of the pattern unless PCRE_EXTENDED is enabled */
+$match = preg_match('/te   #~~~~
+st/', $subject);
+var_dump($match);
+
+/* When PCRE_EXTENDED is enabled, all whitespace data characters and anything
+   that follows an unescaped # on the same line is ignored */
+$match = preg_match('/te    #~~~~
+st/x', $subject);
+var_dump($match);
+]]>
+    </programlisting>
+    &example.outputs;
+    <screen>
+<![CDATA[
+int(1)
+int(0)
+int(1)
+]]>
+    </screen>
+   </example>
+  </para>
  </section>
 
  <section xml:id="regexp.reference.recursive">

-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic