Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Not only is UNIX dead, it's starting to smell really bad. -- Rob Pike


devel / comp.lang.tcl / missing feature for "regsub"

SubjectAuthor
o missing feature for "regsub"clt.to.davebr

1
missing feature for "regsub"

<9691656083396@dlp>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Subject: missing feature for "regsub"
Date: Fri, 24 Jun 22 15:09:56 GMT
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <9691656083396@dlp>
Injection-Info: reader02.eternal-september.org; posting-host="4991b25b0ba0e408a5e818e5bf5be558";
logging-data="19733"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YzwbM/XpTCy+GW/C6nfVW"
Cancel-Lock: sha1:jirHXCSLzDZp+V2q86QyFUHswgU=
 by: clt.to.davebr@dfgh.net - Fri, 24 Jun 2022 15:09 UTC

The Tcl string functions are often faster than regexp (and regsub) for fairly complex string manipulations.

For instance to convert snake to camel case:

join [lmap x [split $str _] {string toupper $x 0 0}] ""

is faster than:

regsub -all {_(\w)} $str {\1}

And the regsub only removes the "_", it does not capitalize the following character.

There are some differences in the results for "odd" cases. The first one will eat multiple or trailing "_", and the regexp will leave some of them.

Dave B

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor