Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5A682200C5A for ; Mon, 13 Mar 2017 11:43:23 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 592B2160B8B; Mon, 13 Mar 2017 10:43:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0E16E160B92 for ; Mon, 13 Mar 2017 11:43:21 +0100 (CET) Received: (qmail 3404 invoked by uid 500); 13 Mar 2017 10:43:21 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 3173 invoked by uid 99); 13 Mar 2017 10:43:21 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Mar 2017 10:43:21 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 9E4F4182319 for ; Mon, 13 Mar 2017 10:43:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.569 X-Spam-Level: X-Spam-Status: No, score=-3.569 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id dCavhKTbhDWc for ; Mon, 13 Mar 2017 10:43:19 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 647205FAD8 for ; Mon, 13 Mar 2017 10:43:18 +0000 (UTC) Received: (qmail 3020 invoked by uid 99); 13 Mar 2017 10:43:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Mar 2017 10:43:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6FEB9DFE7B; Mon, 13 Mar 2017 10:43:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ddekany@apache.org To: notifications@freemarker.incubator.apache.org Date: Mon, 13 Mar 2017 10:43:17 -0000 Message-Id: <64aed908ef5a4717b02391d4dc4723f5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/25] incubator-freemarker git commit: Manual: Document ?groups in more detail archived-at: Mon, 13 Mar 2017 10:43:23 -0000 Repository: incubator-freemarker Updated Branches: refs/heads/2.3 617ad6fc0 -> 0254eca3f Manual: Document ?groups in more detail Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/779e74a8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/779e74a8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/779e74a8 Branch: refs/heads/2.3 Commit: 779e74a844364820a4fefb5531218469ccd6e44b Parents: 83eac15 Author: ddekany Authored: Fri Mar 3 11:33:55 2017 +0100 Committer: ddekany Committed: Fri Mar 3 11:33:55 2017 +0100 ---------------------------------------------------------------------- src/manual/en_US/book.xml | 49 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/779e74a8/src/manual/en_US/book.xml ---------------------------------------------------------------------- diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml index c3e683a..48b754e 100644 --- a/src/manual/en_US/book.xml +++ b/src/manual/en_US/book.xml @@ -7,9 +7,9 @@ to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -13848,9 +13848,48 @@ Matching sub-strings: - "aa/rx;" is "a" per "a/rx" - " ab/r;" is " " per "ab/r" - Note above that groups has worked both with - substring matches and with the result of entire string - matching. + Notes regarding the behavior of the groups + built-in: + + + + It works both with substring matches and with the result + of entire string matching (as it was shown in the above + example) + + + + The first item in the sequence that + groups returns is the whole substring matched + by the regular expression. Hence, the index of the first + explicit regular expression group (with other words, of the + first (...) in the + regular expression) is 1, and not 0. Also, because of this, the + size of the sequence is one more than the number of explicit + regular expression groups. + + + + The size of the sequence returned by + groups only depends on the number of explicit + groups in the regular expression, and so it will be the same + (non-0) even if there was no match found for the regular + expression. Attempting to access an item of the sequence (as in + res?groups[1]) when there was match will + cause an error. Thus, before accessing the groups, you should + always check if there was any match (as in <#if + res>access the groups + here</#if>). + + + + When there's a match for the regular expression, but not + for a certain explicit group inside the regular expression, then + for that group the sequence will contain a 0 length string. So + accessing a group that matches nothing is safe, as far as the + containing regular expression has matched something. + + matches accepts an optional 2nd parameter, the flags. Note that