Article View: comp.lang.tcl
Article #44A behaviour of regexp I cannot understand
From: Olivier
Date: Wed, 14 Oct 2026 15:05
Date: Wed, 14 Oct 2026 15:05
25 lines
1635 bytes
1635 bytes
Hello,
Simply :
set _res [regexp -inline -all {\S+} "dum dummy a b c d c4"]
--> gives a list of 7 items : dum dummy a b c d c4
set _res [regexp -inline -all {c+} "dum dummy a b c d c4"]
--> gives a list of " items : c c
I understand that {c+} acts as a specification, but I cannot understand why {\S+}
acts as a counter-specification, it should return only spaces and/or tabs ?
I found this "trick" on https://wiki.tcl-lang.org/page/Get+a+Certain+Line+From+a+File
I often deal with simulation data where items of line are homogeneously separated
either by space or by tab. So the line can be considered as a list. But in rare case
you stumble on hybrid separators : line defining units or names for instance, that is
how I came to this question. And this "trick" works as a charm !
Olivier.
Technical Details
Message-ID:
<1791990352-1108@newsgrouper.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail From: Olivier <user1108@newsgrouper.org.invalid> Newsgroups: comp.lang.tcl Subject: A behaviour of regexp I cannot understand Date: Wed, 14 Oct 2026 15:05:52 GMT Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: <1791990352-1108@newsgrouper.org> Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user1108 Injection-Date: Wed, 14 Oct 2026 15:05:52 GMT User-Agent: Newsgrouper/0.9.0 Organization: tcltk@vivaldi.net