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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21605 invoked from network); 27 Jan 2023 13:27:29 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Jan 2023 13:27:29 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674826049; b=DM4qYLbosKA/NDudnDuRcC5N9WJHB3cZRkVHlSfLR2EsveSZGtTcrOKrp3gdbfoC7CtYUhokEF m64zNziogZxj5K1/k5YrJ8ZvkXeinmqFV48z0GfzmCiLFP1DNMIdGjNAGZZA+KnNOf65Zh9Kv2 DPqSpE/yJpMJvOk41QURd2meCiNWjkD4/kLb2LrrHMSRoAreF/KAqKjca9h/ipEsqGPXGT1jWQ IedyKXSzcQiMP35eiJ+7syj9ha1haoz+y/PXckvpdVBmQaFX52kdEe+1FOEXZzuI9MQAZV18FS tUrwMGXs2cF0EQWEoy8+nPWj8mCMNzrQUG71vJ3Bz/vCbg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1674826049; bh=RaO3xDSkLDfCbNlou+xx0ftGYOffHbwEV+kGrB5fQqg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=U/V8K2+3dsH2QYHUlqjM2L8kVx8XeEeCgOEo2UNGTrYBVJjWV2yl5V+wxwlZYPDS3aJr2s8skk LlOL9Z4ID7P1j83hjC+bk6v7l3jm0yoIQGhZf/CfGLcwlbm0twNpUmECl72yYlWULeYTiZURFn dMMsBz3HckaVxwLO1nU1WKgr/VqWrWZMbKVWaSrq2VcqsZW53p5Oi2xQsgGBtJeu0Jnu8vbM90 3048Cg6BqN6CgHnZXiB0w+sJ/Yo9BpjSyd5ZjGGoFnhpj+HfceG0+d9XLDh9/CcfVS4z6+xnII P6v929LInq11uw5AcySr66E5eFybPa5V0uevw0ORQ/8Lew==; 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:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=rKPKIOb/2RqkhgdSq6TJ6rlWovSiQHI1JsYstArYSwQ=; b=pR1JfVw46wU+A0ibfiOEoR5rm4 LuLRJz0pMBpyHg2lBO9E0U19NYU2GUhzDf37LEiqeI6dZ38mrPF5ZQcOmDxEtqjrHRckDC0fh1EOT /vKZ9h0lw3h542tUbtOmtP03OWxC87C6FPi2VOR2XtLw9InxgzZTaB+Eneq7uIj64nwG02ongCdHz Sr6NCT+fr9ATJOe8oXP+wLsAZL3UR4Qs6494s5F0o8/hc/d+wwkedpj+qWPvW/cBMmwUm/2IToeUC yXVfIkKzs3ha7NrCrQmBPhLkRdLXX5EzgAYJYwACQ0SbVsatjBeab0XbgygafJ2oVjABTrwkhm0Qr 7i9FWhhw==; Received: by zero.zsh.org with local id 1pLOlM-000Egy-Bw; Fri, 27 Jan 2023 13:27:28 +0000 Authentication-Results: zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none Received: from relay3-d.mail.gandi.net ([217.70.183.195]:50373) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1pLOk2-000EKp-IF; Fri, 27 Jan 2023 13:26:06 +0000 Received: (Authenticated sender: stephane@chazelas.org) by mail.gandi.net (Postfix) with ESMTPSA id 4E46C6000B; Fri, 27 Jan 2023 13:26:04 +0000 (UTC) Date: Fri, 27 Jan 2023 13:26:04 +0000 From: Stephane Chazelas To: Sebastian Gniazdowski Cc: Zsh hackers list Subject: Re: Pattern engine extension for \< and \> support? Message-ID: <20230127132604.h5ouknlasoqdginh@chazelas.org> Mail-Followup-To: Sebastian Gniazdowski , Zsh hackers list References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 51334 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: 2023-01-27 10:01:15 +0000, Sebastian Gniazdowski: > Hi, > in regexps, there are \<, \> and also \b sequences, that match zero-length > string on the word boundary. They are particularly useful for e.g.: > refactoring substitutions, like e.g.: with sed: > > sed -r -i -e 's/\/other/' > > This automatically protects pre/suffixed strings like str_myvar and > myvar_str. In mcedit, I often use \b that's available there (\< and \> do > not work), to obtain the same effect with the regex: [...] Some regexp engines like on BSDs also have [[:<:]] / [[:>:]] for that which would possibly be easy to add to zsh (I'd think anything using backslash would be a no-no). zsh has [[:WORD:]] already as similar to \w. Its [[:<:]], [[:>:]] would need to honour $WORDCHARS as well for consistency. \< / \> come from ex/vi in the 70s AFAIK, \b from perl in the 80s. Perl also has \B and: \b{} Match at Unicode boundary of specified type \B{} Match where corresponding \b{} doesn't match \b Match a \w\W or \W\w boundary \B Match except at a \w\W or \W\w boundary -- Stephane