Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The Shuttle is now going five times the sound of speed. -- Dan Rather, first landing of Columbia


devel / comp.unix.shell / Alternative regexp patterns for perl \K.

SubjectAuthor
* Alternative regexp patterns for perl \K.hongy...@gmail.com
+* Re: Alternative regexp patterns for perl \K.Ed Morton
|`* Re: Alternative regexp patterns for perl \K.hongy...@gmail.com
| `* Re: Alternative regexp patterns for perl \K.Janis Papanagnou
|  `- Re: Alternative regexp patterns for perl \K.hongy...@gmail.com
`* Re: Alternative regexp patterns for perl \K.Janis Papanagnou
 `* Re: Alternative regexp patterns for perl \K.hongy...@gmail.com
  `* Re: Alternative regexp patterns for perl \K.Janis Papanagnou
   `* Re: Alternative regexp patterns for perl \K.hongy...@gmail.com
    `* Re: Alternative regexp patterns for perl \K.Keith Thompson
     +- Re: Alternative regexp patterns for perl \K.Janis Papanagnou
     `* Re: Alternative regexp patterns for perl \K.Geoff Clare
      `- Re: Alternative regexp patterns for perl \K.Keith Thompson

1
Alternative regexp patterns for perl \K.

<be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5033&group=comp.unix.shell#5033

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:5d1:b0:2e0:70c7:1678 with SMTP id d17-20020a05622a05d100b002e070c71678mr21216902qtb.43.1647310991866;
Mon, 14 Mar 2022 19:23:11 -0700 (PDT)
X-Received: by 2002:a05:622a:15c5:b0:2e1:cdc9:dd1c with SMTP id
d5-20020a05622a15c500b002e1cdc9dd1cmr8343932qty.79.1647310991666; Mon, 14 Mar
2022 19:23:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Mon, 14 Mar 2022 19:23:11 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
Subject: Alternative regexp patterns for perl \K.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 15 Mar 2022 02:23:11 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 8
 by: hongy...@gmail.com - Tue, 15 Mar 2022 02:23 UTC

I want to find some alternative regexp patterns of my following operation:

$ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
NKPTS

Any hints?

Regards,
HZ

Re: Alternative regexp patterns for perl \K.

<t0qfgv$n4e$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5040&group=comp.unix.shell#5040

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Tue, 15 Mar 2022 11:40:00 -0500
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <t0qfgv$n4e$1@dont-email.me>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 15 Mar 2022 16:39:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="01377783e5b0c310745d4f7285a319eb";
logging-data="23694"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//LuNidWp4NWiyobwodo3Y"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:ZwgeAeEJrSVvaQ8NnWJAKFwShS8=
In-Reply-To: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 220315-2, 3/15/2022), Outbound message
 by: Ed Morton - Tue, 15 Mar 2022 16:40 UTC

On 3/14/2022 9:23 PM, hongy...@gmail.com wrote:
> I want to find some alternative regexp patterns of my following operation:
>
> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
> NKPTS
>
> Any hints?
>
> Regards,
> HZ

google. dear god learn to use google.

Re: Alternative regexp patterns for perl \K.

<da8c0bc8-05a6-425b-b05c-f90c93974527n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5085&group=comp.unix.shell#5085

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:7dc8:0:b0:2e1:b3ec:6666 with SMTP id c8-20020ac87dc8000000b002e1b3ec6666mr6050186qte.556.1647566824174;
Thu, 17 Mar 2022 18:27:04 -0700 (PDT)
X-Received: by 2002:ac8:5889:0:b0:2e1:afa2:65a9 with SMTP id
t9-20020ac85889000000b002e1afa265a9mr5958955qta.268.1647566824035; Thu, 17
Mar 2022 18:27:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Thu, 17 Mar 2022 18:27:03 -0700 (PDT)
In-Reply-To: <t0qfgv$n4e$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com> <t0qfgv$n4e$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <da8c0bc8-05a6-425b-b05c-f90c93974527n@googlegroups.com>
Subject: Re: Alternative regexp patterns for perl \K.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 18 Mar 2022 01:27:04 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 15
 by: hongy...@gmail.com - Fri, 18 Mar 2022 01:27 UTC

On Wednesday, March 16, 2022 at 12:40:06 AM UTC+8, Ed Morton wrote:
> On 3/14/2022 9:23 PM, hongy...@gmail.com wrote:
> > I want to find some alternative regexp patterns of my following operation:
> >
> > $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
> > NKPTS
> >
> > Any hints?
> >
> > Regards,
> > HZ
> google. dear god learn to use google.

I tried googling it, and it seems that this feature of Perl is a very peculiar implementation that hasn't direct counterpart in other languages.

HZ

Re: Alternative regexp patterns for perl \K.

<t10opu$8qc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5086&group=comp.unix.shell#5086

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Fri, 18 Mar 2022 02:55:10 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <t10opu$8qc$1@dont-email.me>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t0qfgv$n4e$1@dont-email.me>
<da8c0bc8-05a6-425b-b05c-f90c93974527n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 01:55:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f1aa0ff20907ebe22a9eba7bb989115b";
logging-data="9036"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WC3O8Jb3cn5FElLuw22dT"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:6XBktTjsee+Yaca0KEk0j/Ef9bU=
In-Reply-To: <da8c0bc8-05a6-425b-b05c-f90c93974527n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 18 Mar 2022 01:55 UTC

On 18.03.2022 02:27, hongy...@gmail.com wrote:
> On Wednesday, March 16, 2022 at 12:40:06 AM UTC+8, Ed Morton wrote:
>> On 3/14/2022 9:23 PM, hongy...@gmail.com wrote:
>>> I want to find some alternative regexp patterns of my following operation:
>>>
>>> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
>>> NKPTS
>>>
>>> Any hints?
>>>
>>> Regards,
>>> HZ
>> google. dear god learn to use google.
>
> I tried googling it, and it seems that this feature of Perl is a very
> peculiar implementation that hasn't direct counterpart in other
> languages.

Try: man pcrepattern

If you want help you should either explain what you actually want to
match, or tell us what \K is supposed to do in above grep context,
especially in case of non-standard patterns and not widely supported
extensions.

Janis

>
> HZ
>

Re: Alternative regexp patterns for perl \K.

<t10qpi$ja8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5087&group=comp.unix.shell#5087

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Fri, 18 Mar 2022 03:29:06 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <t10qpi$ja8$1@dont-email.me>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Mar 2022 02:29:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f1aa0ff20907ebe22a9eba7bb989115b";
logging-data="19784"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IRUr9A6ZuL9AT5ZWz1jlh"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:OrrZkBVlwMtkczX78CHjxZjX0Xo=
In-Reply-To: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
 by: Janis Papanagnou - Fri, 18 Mar 2022 02:29 UTC

On 15.03.2022 03:23, hongy...@gmail.com wrote:
> I want to find some alternative regexp patterns of my following operation:
>
> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
> NKPTS
>
> Any hints?

Avoid non-standard options (like grep's -P and -o), use standard tools

sed 's/.*::[ ]*\([^ ]\+\).*/\1/'

Janis

>
> Regards,
> HZ
>

Re: Alternative regexp patterns for perl \K.

<09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5088&group=comp.unix.shell#5088

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:5bc9:0:b0:435:8ee0:f9b8 with SMTP id t9-20020ad45bc9000000b004358ee0f9b8mr5484094qvt.82.1647571176468;
Thu, 17 Mar 2022 19:39:36 -0700 (PDT)
X-Received: by 2002:ad4:5ca3:0:b0:440:f131:a7a4 with SMTP id
q3-20020ad45ca3000000b00440f131a7a4mr3568659qvh.16.1647571176321; Thu, 17 Mar
2022 19:39:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Thu, 17 Mar 2022 19:39:36 -0700 (PDT)
In-Reply-To: <t10qpi$ja8$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com> <t10qpi$ja8$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
Subject: Re: Alternative regexp patterns for perl \K.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 18 Mar 2022 02:39:36 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: hongy...@gmail.com - Fri, 18 Mar 2022 02:39 UTC

On Friday, March 18, 2022 at 10:29:11 AM UTC+8, Janis Papanagnou wrote:
> On 15.03.2022 03:23, hongy...@gmail.com wrote:
> > I want to find some alternative regexp patterns of my following operation:
> >
> > $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
> > NKPTS
> >
> > Any hints?
> Avoid non-standard options (like grep's -P and -o), use standard tools
>
> sed 's/.*::[ ]*\([^ ]\+\).*/\1/'

Thank you. The following version is clearer:

$ echo 'public , save :: NKPTS ! - max. no. of kpoints' | sed -E 's/.*::[ ]*([^ ]+).*/\1/'
NKPTS

HZ

Re: Alternative regexp patterns for perl \K.

<aca210a1-9597-4f1a-999c-c25294f11b55n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5089&group=comp.unix.shell#5089

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:6407:0:b0:67e:4423:7127 with SMTP id y7-20020a376407000000b0067e44237127mr2945516qkb.526.1647571423019;
Thu, 17 Mar 2022 19:43:43 -0700 (PDT)
X-Received: by 2002:ad4:5ec5:0:b0:440:d431:b0a4 with SMTP id
jm5-20020ad45ec5000000b00440d431b0a4mr5764852qvb.91.1647571422875; Thu, 17
Mar 2022 19:43:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Thu, 17 Mar 2022 19:43:42 -0700 (PDT)
In-Reply-To: <t10opu$8qc$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t0qfgv$n4e$1@dont-email.me> <da8c0bc8-05a6-425b-b05c-f90c93974527n@googlegroups.com>
<t10opu$8qc$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <aca210a1-9597-4f1a-999c-c25294f11b55n@googlegroups.com>
Subject: Re: Alternative regexp patterns for perl \K.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 18 Mar 2022 02:43:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 53
 by: hongy...@gmail.com - Fri, 18 Mar 2022 02:43 UTC

On Friday, March 18, 2022 at 9:55:16 AM UTC+8, Janis Papanagnou wrote:
> On 18.03.2022 02:27, hongy...@gmail.com wrote:
> > On Wednesday, March 16, 2022 at 12:40:06 AM UTC+8, Ed Morton wrote:
> >> On 3/14/2022 9:23 PM, hongy...@gmail.com wrote:
> >>> I want to find some alternative regexp patterns of my following operation:
> >>>
> >>> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
> >>> NKPTS
> >>>
> >>> Any hints?
> >>>
> >>> Regards,
> >>> HZ
> >> google. dear god learn to use google.
> >
> > I tried googling it, and it seems that this feature of Perl is a very
> > peculiar implementation that hasn't direct counterpart in other
> > languages.
> Try: man pcrepattern

Yes. It does include the following related description:

$ man pcrepattern |grep -A14 -B2 'The escape sequence \\K'
Resetting the match start

The escape sequence \K causes any previously matched characters not to be included in the final matched sequence. For example, the pattern:

foo\Kbar

matches "foobar", but reports that it has matched "bar". This feature is similar to a lookbehind assertion (described below). However, in this case, the
part of the subject before the real match does not have to be of fixed length, as lookbehind assertions do. The use of \K does not interfere with the set‐
ting of captured substrings. For example, when the pattern

(foo)\Kbar

matches "foobar", the first substring is still set to "foo".

Perl documents that the use of \K within assertions is "not well defined". In PCRE, \K is acted upon when it occurs inside positive assertions, but is ig‐
nored in negative assertions. Note that when a pattern such as (?=ab\K) matches, the reported start of the match can be greater than the end of the match.

Best,
HZ

Re: Alternative regexp patterns for perl \K.

<t160ti$a48$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5127&group=comp.unix.shell#5127

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Sun, 20 Mar 2022 02:44:18 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <t160ti$a48$1@dont-email.me>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t10qpi$ja8$1@dont-email.me>
<09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 20 Mar 2022 01:44:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="264de471b643a9b4fa6e08239b6feb4a";
logging-data="10376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fKC4IY03ox1QpipvIZE3L"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Am3MYsXJv7P9cbMEqC7h64aqb6s=
In-Reply-To: <09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sun, 20 Mar 2022 01:44 UTC

On 18.03.2022 03:39, hongy...@gmail.com wrote:
> On Friday, March 18, 2022 at 10:29:11 AM UTC+8, Janis Papanagnou wrote:
>> On 15.03.2022 03:23, hongy...@gmail.com wrote:
>>> I want to find some alternative regexp patterns of my following operation:
>>>
>>> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
>>> NKPTS
>>>
>>> Any hints?
>> Avoid non-standard options (like grep's -P and -o), use standard tools
>>
>> sed 's/.*::[ ]*\([^ ]\+\).*/\1/'
>
> Thank you. The following version is clearer:

Maybe clearer but obviously non-standard.

>
> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | sed -E 's/.*::[ ]*([^ ]+).*/\1/'
> NKPTS

What is option -E doing?
It's neither defined by POSIX nor available in my version of sed.
(I suppose it makes the regexp meta-character escapes unnecessary,
and you instead would have to escape the meta-characters that are
used literally?)

Janis

>
> HZ
>

Re: Alternative regexp patterns for perl \K.

<366e6c3f-219d-4d43-80ea-15c11d937354n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5129&group=comp.unix.shell#5129

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ae9:e411:0:b0:67e:616f:400a with SMTP id q17-20020ae9e411000000b0067e616f400amr4735957qkc.645.1647745357866;
Sat, 19 Mar 2022 20:02:37 -0700 (PDT)
X-Received: by 2002:ac8:24d:0:b0:2d5:e1f1:d492 with SMTP id
o13-20020ac8024d000000b002d5e1f1d492mr12434790qtg.348.1647745357642; Sat, 19
Mar 2022 20:02:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 19 Mar 2022 20:02:37 -0700 (PDT)
In-Reply-To: <t160ti$a48$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.138; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.138
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t10qpi$ja8$1@dont-email.me> <09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
<t160ti$a48$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <366e6c3f-219d-4d43-80ea-15c11d937354n@googlegroups.com>
Subject: Re: Alternative regexp patterns for perl \K.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 20 Mar 2022 03:02:37 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 33
 by: hongy...@gmail.com - Sun, 20 Mar 2022 03:02 UTC

On Sunday, March 20, 2022 at 9:44:23 AM UTC+8, Janis Papanagnou wrote:
> On 18.03.2022 03:39, hongy...@gmail.com wrote:
> > On Friday, March 18, 2022 at 10:29:11 AM UTC+8, Janis Papanagnou wrote:
> >> On 15.03.2022 03:23, hongy...@gmail.com wrote:
> >>> I want to find some alternative regexp patterns of my following operation:
> >>>
> >>> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
> >>> NKPTS
> >>>
> >>> Any hints?
> >> Avoid non-standard options (like grep's -P and -o), use standard tools
> >>
> >> sed 's/.*::[ ]*\([^ ]\+\).*/\1/'
> >
> > Thank you. The following version is clearer:
> Maybe clearer but obviously non-standard.
> >
> > $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | sed -E 's/.*::[ ]*([^ ]+).*/\1/'
> > NKPTS
> What is option -E doing?
> It's neither defined by POSIX nor available in my version of sed.
> (I suppose it makes the regexp meta-character escapes unnecessary,
> and you instead would have to escape the meta-characters that are
> used literally?)

$ sed --help | grep -A2 -- '^[ ]*-E'
-E, -r, --regexp-extended
use extended regular expressions in the script
(for portability use POSIX -E).

$ sed --version
sed (GNU sed) 4.7

HZ

Re: Alternative regexp patterns for perl \K.

<87pmmg2upb.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5140&group=comp.unix.shell#5140

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Sun, 20 Mar 2022 14:13:52 -0700
Organization: None to speak of
Lines: 71
Message-ID: <87pmmg2upb.fsf@nosuchdomain.example.com>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t10qpi$ja8$1@dont-email.me>
<09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
<t160ti$a48$1@dont-email.me>
<366e6c3f-219d-4d43-80ea-15c11d937354n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="6cf45b1d863d5b1adfbc119b5df06540";
logging-data="18137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UvHB4WKY42tGhjY9x1eL+"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:8R0s83H8xU39L2QRtBVV74scGqQ=
sha1:IFrj377VOEL4ma+bcpdTcnPPF6w=
 by: Keith Thompson - Sun, 20 Mar 2022 21:13 UTC

"hongy...@gmail.com" <hongyi.zhao@gmail.com> writes:
> On Sunday, March 20, 2022 at 9:44:23 AM UTC+8, Janis Papanagnou wrote:
>> On 18.03.2022 03:39, hongy...@gmail.com wrote:
>> > On Friday, March 18, 2022 at 10:29:11 AM UTC+8, Janis Papanagnou wrote:
>> >> On 15.03.2022 03:23, hongy...@gmail.com wrote:
>> >>> I want to find some alternative regexp patterns of my following operation:
>> >>>
>> >>> $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | grep -Po '::[ ]*\K[^ ]+'
>> >>> NKPTS
>> >>>
>> >>> Any hints?
>> >> Avoid non-standard options (like grep's -P and -o), use standard tools
>> >>
>> >> sed 's/.*::[ ]*\([^ ]\+\).*/\1/'
>> >
>> > Thank you. The following version is clearer:
>> Maybe clearer but obviously non-standard.
>> >
>> > $ echo 'public , save :: NKPTS ! - max. no. of kpoints' | sed -E 's/.*::[ ]*([^ ]+).*/\1/'
>> > NKPTS
>> What is option -E doing?
>> It's neither defined by POSIX nor available in my version of sed.
>> (I suppose it makes the regexp meta-character escapes unnecessary,
>> and you instead would have to escape the meta-characters that are
>> used literally?)
>
> $ sed --help | grep -A2 -- '^[ ]*-E'
> -E, -r, --regexp-extended
> use extended regular expressions in the script
> (for portability use POSIX -E).
>
> $ sed --version
> sed (GNU sed) 4.7

That appears to be an error in GNU sed. Here's the relevant excerpt
from sed's "info" documentation:

'-E'
'-r'
'--regexp-extended'
Use extended regular expressions rather than basic regular
expressions. Extended regexps are those that 'egrep' accepts; they
can be clearer because they usually have fewer backslashes.
Historically this was a GNU extension, but the '-E' extension has
since been added to the POSIX standard
(http://austingroupbugs.net/view.php?id=528), so use '-E' for
portability. GNU sed has accepted '-E' as an undocumented option
for years, and *BSD seds have accepted '-E' for years as well, but
scripts that use '-E' might not port to other older systems. *Note
Extended regular expressions: ERE syntax.

The austingroupbugs.net web page is an enhancement request, not an
actual update to POSIX. POSIX itself:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html

does not mention the "-E" option.

I'll submit a bug report for GNU sed.

The enhancement request was submitted in 2011. The resolution is
"Accepted As Marked" and the status is "Applied", so I'm not entirely
sure what's going on. But in any case, The Open Group Base
Specifications Issue 7, 2018 edition doesn't mention "-E".

(Janis, what version of sed are you using?)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Alternative regexp patterns for perl \K.

<t18vgl$lt9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5143&group=comp.unix.shell#5143

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Mon, 21 Mar 2022 05:38:45 +0100
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <t18vgl$lt9$1@dont-email.me>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t10qpi$ja8$1@dont-email.me>
<09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
<t160ti$a48$1@dont-email.me>
<366e6c3f-219d-4d43-80ea-15c11d937354n@googlegroups.com>
<87pmmg2upb.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 21 Mar 2022 04:38:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a48591383945bfd3055d6e6b66b5f5e7";
logging-data="22441"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19a9PBENhQcpDb/xlMSftH1"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:X54OgJfrHZROYWJ4G11RqGsj70E=
In-Reply-To: <87pmmg2upb.fsf@nosuchdomain.example.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Mon, 21 Mar 2022 04:38 UTC

On 20.03.2022 22:13, Keith Thompson wrote:
>
> (Janis, what version of sed are you using?)

I'm working on a "legacy" (sort of) system...

$ sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.

My statement "nor available in my version of sed"
was meant as "not documented in the sed man page"
and also not displayed as option when calling sed
without arguments.

Given your quote that "GNU sed has accepted '-E'
as an undocumented option for years" I confirmed
its (undocumented) existence also on my system.

Janis

Re: Alternative regexp patterns for perl \K.

<52dmgi-tfa.ln1@ID-313840.user.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5145&group=comp.unix.shell#5145

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geo...@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Mon, 21 Mar 2022 14:01:09 +0000
Lines: 14
Message-ID: <52dmgi-tfa.ln1@ID-313840.user.individual.net>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t10qpi$ja8$1@dont-email.me>
<09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
<t160ti$a48$1@dont-email.me>
<366e6c3f-219d-4d43-80ea-15c11d937354n@googlegroups.com>
<87pmmg2upb.fsf@nosuchdomain.example.com>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net joLUgCg8rrHsZyC9/2cwKgwwxRfVTLldPNChL21mqM7rAxu9ln
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:FL+dbdMJe4xylncO4+NLAT/MlLM=
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
 by: Geoff Clare - Mon, 21 Mar 2022 14:01 UTC

Keith Thompson wrote:

> The enhancement request was submitted in 2011. The resolution is
> "Accepted As Marked" and the status is "Applied", so I'm not entirely
> sure what's going on. But in any case, The Open Group Base
> Specifications Issue 7, 2018 edition doesn't mention "-E".

"Applied" means the edits have been made in the (troff) source of SUS.
In this specific case the edit was applied long enough ago that it
was included in the latest draft (2.1) of the next revision (Issue 8)
that was made available to reviewers in August 2021.

--
Geoff Clare <netnews@gclare.org.uk>

Re: Alternative regexp patterns for perl \K.

<87ils72dmc.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5149&group=comp.unix.shell#5149

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Alternative regexp patterns for perl \K.
Date: Mon, 21 Mar 2022 14:35:07 -0700
Organization: None to speak of
Lines: 21
Message-ID: <87ils72dmc.fsf@nosuchdomain.example.com>
References: <be51d4e1-1f4c-4a19-8453-7ea49a402943n@googlegroups.com>
<t10qpi$ja8$1@dont-email.me>
<09ceb221-2914-4507-8056-e2c617761752n@googlegroups.com>
<t160ti$a48$1@dont-email.me>
<366e6c3f-219d-4d43-80ea-15c11d937354n@googlegroups.com>
<87pmmg2upb.fsf@nosuchdomain.example.com>
<52dmgi-tfa.ln1@ID-313840.user.individual.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="dafd301aaff877eda9465debed94df06";
logging-data="5973"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/d3XMQmG2viDLYJt1OUbLS"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:UwyeAPzUORiLpb8YKeTOgWw7Wwo=
sha1:nCOiyOp/EYSNITkbnmeea41Qr7A=
 by: Keith Thompson - Mon, 21 Mar 2022 21:35 UTC

Geoff Clare <geoff@clare.See-My-Signature.invalid> writes:
> Keith Thompson wrote:
>> The enhancement request was submitted in 2011. The resolution is
>> "Accepted As Marked" and the status is "Applied", so I'm not entirely
>> sure what's going on. But in any case, The Open Group Base
>> Specifications Issue 7, 2018 edition doesn't mention "-E".
>
> "Applied" means the edits have been made in the (troff) source of SUS.
> In this specific case the edit was applied long enough ago that it
> was included in the latest draft (2.1) of the next revision (Issue 8)
> that was made available to reviewers in August 2021.

Thanks. I've copied that information to the bug report.

https://lists.gnu.org/archive/html/bug-sed/2022-03/msg00000.html
https://lists.gnu.org/archive/html/bug-sed/2022-03/msg00001.html

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor