Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

RAM wasn't built in a day.


devel / comp.lang.tcl / possible "regsub/regexp" bug

SubjectAuthor
* possible "regsub/regexp" bugaotto1968
`- Re: possible "regsub/regexp" bugSchelte

1
possible "regsub/regexp" bug

<t9job7$1oadh$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19608&group=comp.lang.tcl#19608

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: possible "regsub/regexp" bug
Date: Thu, 30 Jun 2022 10:53:59 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <t9job7$1oadh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 30 Jun 2022 08:53:59 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6aafc7df617abae3b206c886c0a7d26d";
logging-data="1845681"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XxLeIylxlh6wSgc0L1FoQkCSGGYrX/1M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:Gihll89qPQSuuVofnsECopoYJmM=
Content-Language: en-US
 by: aotto1968 - Thu, 30 Jun 2022 08:53 UTC

Hi,

I have the following regexp:

> "(?!\()([A-Z][a-z]+)(?!\))"

and I want to match

> "MkObjectLogC"

into:

> "(?:Mk)?(?:Object)?(?:Log)?C"

using the code

> set match "MkObjectLogC"
> while {[regsub {(?!\()([A-Z][a-z]+)(?!\))} $match {(?:\1)?} match]} {}

but the solution is:

> "(?:Mk)?(?:(?:(?:(?:(?:Ob)?j)?e)?c)?t)?(?:(?:Lo)?g)?C"

the online regexp is ok:

> https://regex101.com/r/cWJrDK/1

mfg

Re: possible "regsub/regexp" bug

<nnd$203929e0$69f24f4a@47e2c85bbc07e978>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19609&group=comp.lang.tcl#19609

  copy link   Newsgroups: comp.lang.tcl
Date: Thu, 30 Jun 2022 12:40:39 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Subject: Re: possible "regsub/regexp" bug
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <t9job7$1oadh$1@dont-email.me>
From: nospam@wanadoo.nl (Schelte)
In-Reply-To: <t9job7$1oadh$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$203929e0$69f24f4a@47e2c85bbc07e978>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!aioe.org!newsfeed.CARNet.hr!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 21
Injection-Date: Thu, 30 Jun 2022 12:40:39 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1416
 by: Schelte - Thu, 30 Jun 2022 10:40 UTC

On 30/06/2022 10:53, aotto1968 wrote:
> using the code
>
> > set match "MkObjectLogC"
> > while {[regsub {(?!\()([A-Z][a-z]+)(?!\))} $match {(?:\1)?} match]} {}
>
> but the solution is:
>
> > "(?:Mk)?(?:(?:(?:(?:(?:Ob)?j)?e)?c)?t)?(?:(?:Lo)?g)?C"
>
> the online regexp is ok:
>
That's because you repeatedly reprocess the result of the previous
substitution. The online regexp does the processing in one go. If you do
the same with regsub, you get the requested result:

regsub -all {(?!\()([A-Z][a-z]+)(?!\))} $match {(?:\1)?} match

Schelte.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor