Subject: bug#22943: sed: + intepreted twice

From: Jim Meyering <[email-masked]>
Date: Tue, 8 Mar 2016 09:40:08 -0800

tags 22943 notabug
close 22943
thanks

On Tue, Mar 8, 2016 at 8:39 AM, Davide Brini <[email-masked]> wrote:
> On Tue, 8 Mar 2016 12:06:43 +0000, "Dam, Jesse van" <[email-masked]>
> wrote:
...
> By default sed uses basic regular expressions (BRE), where "+" is not a
> special character, so in your example it's matched literally and you're
> getting the expected result.
>
> To do what you wanted you need extended REs (ERE), as in
>
> $ echo '+710+1869' | sed -r 's/(.[0-9]+).*/\1/g'
> +710
>
> or you need to tell sed to enable "+" as a nonstandard BRE metacharacter by
> escaping it:
>
> $ echo '+710+1869' | sed 's/\(.[0-9]\+\).*/\1/g'
> +710

Thank you for helping triage, Davide.
Since this is not a bug, I'm marking it as "notabug"
in the issue tracker with a comment above. Also closing it.