From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7550 invoked from network); 9 Dec 2023 06:23:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Dec 2023 06:23:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1702103016; b=lQ4tQzUPcUEQlTnAYYnfJeaGNUySPEcdcFGC+sMGGgk+DrFfiS7qCNcj3J+baHLnrMnuhO96zZ ajxNWDEhjdQEVo4F2deUkciIhBPRnNpEstEQGN9PEZSqoTV7gtPJBAJQhk/6jca6hEiG/V73Eh kzhA7cCxAog3/4b3SJjxy3+odE5My1jna0wM9BpV8WAfjgjqNil/u0wo+HDV1KeauBKxMY3PU8 t2fl7L9V4164Cm83uy451oif4knIZKGGbKJaQDmcubKL+Qmqea4ePDImKSWokIhKXQIgcPAywE wXqzCBUWMwHUC60brNqsapy/h2m7YUKaXGPhLY8/z9uJdw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f44.google.com) smtp.remote-ip=209.85.218.44; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1702103016; bh=OGrn3FYVpl67PhhfCHD/TEQnnu3zjOQOFjUlsXEv4b8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=pJv6IIL0Vv/FRDANQr+6EW+MsztezHOMk41c9jWnynL8N5WcrEoisA+JaKNfy3e9GlNQVwR4Zq VT0MyKMUQc/tCPadqIQ1EPR+2PyupW7/3feG8nz3Z9HzEAYGqOXjwtn/7V+DbbsEfxQjeIxcVJ HJCIjE/yN3pQXCcs8sUfpyxPhrPx7a0LqvXrS3jbNb0JlnjX/RDnfjVmUtui+jiWEdpA98t8u+ YKf9g2KcrauWQ2SUHA5ktTpDHN2UkdQE/kzzijNSa+yNiIWjMa+at8ldByZRroEa+snCSg+fB/ b2iWeC73gwxfuUh7PA4ebOmQlZhDIvGf/QixXcfjnXMdZw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=QR4ek07sq9dXuJauNk/aVmEiiEYt4W2USph7opzZnVU=; b=Wj9lqwifrsHp3+2xP5OVp8IPQ9 xFiV9idoyUTm2Ut74T2wQPSCltcl32VPv7rWS541dqXUU18+S/O2oqeCbrD/Xr1qVBQZfOBOzRLKT VuquK3FEYK/GM1IDlDbPT72xiLt0Ym6uHRiwtcbYwIzD6HPuIg6Zmxj2ZYgX3lGU0k7qQYGO3hd8n NCNpn0WTXJjm/nqeOzrww4zJPVWIpIibta5pIxUVslEXKpxHzq5vzVCtHgTO26HmkhrVmGVwksYtK Ch6F1MFxa61v3rZ/HOTrhrAjLOo3vjn20LhqhaG3Rqi1XwszhotvrkqXhv8/hqESl6NqmVng08rnO pZTBMX7A==; Received: by zero.zsh.org with local id 1rBqkR-000GYw-PR; Sat, 09 Dec 2023 06:23:35 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f44.google.com) smtp.remote-ip=209.85.218.44; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f44.google.com ([209.85.218.44]:46537) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rBqkE-000GHp-0h; Sat, 09 Dec 2023 06:23:22 +0000 Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a1caddd6d28so359705566b.1 for ; Fri, 08 Dec 2023 22:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1702103001; x=1702707801; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QR4ek07sq9dXuJauNk/aVmEiiEYt4W2USph7opzZnVU=; b=m5WCvyGsBkVbZAfXiK5f9aRJdjBQFGEeANaCgeb1j6WlqlTfPI0F0urrNFR5tueGGV J98/o/vdSaYyO3ceu+GNsTqHV7TE8XkatgQU5kcn+eE1z+wsquG4xee/j5SJ/PkYhzG5 xcFypHA29Zx1uek7MgwhPZByN/MmdkS5J5cvvRI9uea2qtGyfG768WwhOE3cypr21arU mk0LRTmKejp6A6+v3WE7y+rNXoxoWBhFN3/4RZs0Z7tDt2LGucCkz6HATqfF2M/cbjv4 rMApDrHNSE0K2fGHHZ2QWizZVXjixUrMtig+OTgThjnewG7ycYoHqCi+8sBDF21fZLbn N+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702103001; x=1702707801; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QR4ek07sq9dXuJauNk/aVmEiiEYt4W2USph7opzZnVU=; b=DSelVneHCLQouzB7exs7OAiZLR05MO/oO/HtXQ6o6Nmpbx7lid6LwCZbhiUic49Vjn 35Tts2jy1fSufBcTYu4g9CF5Dwl6irylAk0PSonQOn2co8MlIxP7Nf9Q8BObcIv4ffDZ YUIpIFkwHuPXlYShA4WAJT3jQL2FIQAbmvMiLo26XJDOwEoK3coiie0/xhZs8GtZKDTB XDk11Wdt5yLUVnO/hV/4mpzmjGBJa3X+H8CiwBq0ZJtD4nFvqcUbD4EE9eHmcfOVc8pn qf4aplwLd6Bdm3xTRBClTwvRRs3clwtOJm/fA2o5v1WH/kzaGr8h8gTMPP2ywdOMhiNA HtkQ== X-Gm-Message-State: AOJu0YxB5eT+9koYBfrYrAmJevzqTzJmH3Pfjv3QArGbWfqIvCmyExAj iSfoO2FRGapVDNsy3+FntvrE+qL+Bsaj2OuNP/Z/0A== X-Google-Smtp-Source: AGHT+IHTW2R4XNws2AbdgkgyD3Ht36s2KEiwgfyBFMP6eHh1Jn64gsONpJOGxighkWuOoT6zoqJNwCA9wJor1oUAykg= X-Received: by 2002:a17:906:1083:b0:a19:a19b:426a with SMTP id u3-20020a170906108300b00a19a19b426amr316213eju.213.1702103001308; Fri, 08 Dec 2023 22:23:21 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Fri, 8 Dec 2023 22:23:10 -0800 Message-ID: Subject: =?UTF-8?Q?Re=3A_=5BBUG=5D_=60=24match=60_is_haunting_my_regex=E2=80=99s_trailing?= =?UTF-8?Q?=2C_optional=2C_capture?= To: chris0e3@gmail.com Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52387 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Fri, Dec 8, 2023 at 9:14=E2=80=AFPM wrote: > > setopt rematch_pcre > [[ 'REQUIRE. OPT' =3D~ 'REQUIRE.(\s*OPT)?' ]] && printf '\tA. =E2=80=B9= %s=E2=80=BA\n' $match > [[ 'REQUIRE.' =3D~ 'REQUIRE.(\s*OPT)?' ]] && printf '\tB. =E2=80=B9= %s=E2=80=BA\n' $match Aside, you should use e.g. "$match[@]" there (including the quotes) or you'll be surprised when there is more than one back reference. > It looks like: if there is a match, but no captures are matched then `$ma= tch` is not cleared. The output of your latter example is certainly not consistent with e.g. setopt extendedglob [[ 'REQUIRE.' =3D (#b)REQUIRE.(*OPT)(#c0,1) ]] && printf '\tB. =E2=80=B9%s= =E2=80=BA\n' $match And I can reproduce your example with the most recent git checkout, as well. Oliver recently updated to pcre2, so if a patch appears, you may be on your own to backport it.