sed regex oddness

2016-05-03 Thread Philip Rhoades
People, This behaves as expected: echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//g' but I would expect this: echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//' to delete the first string of digits but it doesn't do anything . . clarification from a sed guru?

Re: sed regex oddness

2016-05-03 Thread Kenneth Wolcott
On Tue, May 3, 2016 at 10:44 PM, Philip Rhoades wrote: > People, > > This behaves as expected: > > echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//g' > > but I would expect this: > > echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//' > > to delete the first string

Re: sed regex oddness

2016-05-04 Thread dwoody5654
On 05/04/2016 12:44 AM, Philip Rhoades wrote: People, This behaves as expected: echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//g' but I would expect this: echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//' to delete the first string of digits but it doesn't

Re: sed regex oddness

2016-05-04 Thread Nohk Two
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On 2016/5/4 15:50, dwoody5654 wrote: > On 05/04/2016 12:44 AM, Philip Rhoades wrote: >> People, >> >> This behaves as expected: >> >> echo 'This is a test 12335 and 669384 535xy4' | sed >> 's/[0-9]*//g' >> >> but I would expect this: >> >> echo '

Re: sed regex oddness

2016-05-04 Thread Jon LaBadie
On Wed, May 04, 2016 at 03:44:26PM +1000, Philip Rhoades wrote: > People, > > This behaves as expected: > > echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//g' > > but I would expect this: > > echo 'This is a test 12335 and 669384 535xy4' | sed 's/[0-9]*//' > > to delete the

Re: sed regex oddness

2016-05-04 Thread Samuel Sieb
On 05/04/2016 10:09 AM, Jon LaBadie wrote: The '*' means "zero or more digits". Don't forget that zero. The first match is where there are zero digits, i.e. at the beginning of the line. So sed replaces it with "//" (nothing). However, usually regexps are greedy so they match as much as possib

Re: sed regex oddness

2016-05-04 Thread Jon LaBadie
On Wed, May 04, 2016 at 10:42:20AM -0700, Samuel Sieb wrote: > On 05/04/2016 10:09 AM, Jon LaBadie wrote: > > The '*' means "zero or more digits". Don't forget that zero. > > The first match is where there are zero digits, i.e. at the > > beginning of the line. So sed replaces it with "//" (nothi

Re: sed regex oddness

2016-05-04 Thread Samuel Sieb
On 05/04/2016 11:32 AM, Jon LaBadie wrote: Traditionally sed has used basic RE syntax not the extended syntax that includes "+". If the OP uses a sed such as exists on my systems, you can get extended RE syntax with the "-r" option. sed -r 's/[0-9]+//' Samuel, does your sed support extende

Re: sed regex oddness

2016-05-04 Thread Markus Schönhaber
Samuel Sieb, Wed, 4 May 2016 10:42:20 -0700: > On 05/04/2016 10:09 AM, Jon LaBadie wrote: >> The '*' means "zero or more digits". Don't forget that zero. >> The first match is where there are zero digits, i.e. at the >> beginning of the line. So sed replaces it with "//" (nothing). >> > However,

Re: sed regex oddness

2016-05-04 Thread Samuel Sieb
On 05/04/2016 03:29 PM, Markus Schönhaber wrote: Samuel Sieb, Wed, 4 May 2016 10:42:20 -0700: On 05/04/2016 10:09 AM, Jon LaBadie wrote: The '*' means "zero or more digits". Don't forget that zero. The first match is where there are zero digits, i.e. at the beginning of the line. So sed repl

Re: sed regex oddness

2016-05-05 Thread Patrick O'Callaghan
On Wed, 2016-05-04 at 16:24 -0700, Samuel Sieb wrote: > Oh, right.  I never use a regexp that can match nothing, so I missed  > that. :-) You never use '*'? poc -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: http://lists.fedoraproject.org/admin/

Re: sed regex oddness

2016-05-05 Thread Ian Malone
On 5 May 2016 at 10:27, Patrick O'Callaghan wrote: > On Wed, 2016-05-04 at 16:24 -0700, Samuel Sieb wrote: >> Oh, right. I never use a regexp that can match nothing, so I missed >> that. :-) > > You never use '*'? > I guess he meant "match *only* nothing", most of the time using * you'll still u

Re: sed regex oddness

2016-05-05 Thread Samuel Sieb
On 05/05/2016 03:35 AM, Ian Malone wrote: On 5 May 2016 at 10:27, Patrick O'Callaghan wrote: On Wed, 2016-05-04 at 16:24 -0700, Samuel Sieb wrote: Oh, right. I never use a regexp that can match nothing, so I missed that. :-) You never use '*'? I guess he meant "match *only* nothing", most

Re: sed regex oddness

2016-05-05 Thread Jon LaBadie
On Thu, May 05, 2016 at 08:56:51AM -0700, Samuel Sieb wrote: > On 05/05/2016 03:35 AM, Ian Malone wrote: > > On 5 May 2016 at 10:27, Patrick O'Callaghan wrote: > > > On Wed, 2016-05-04 at 16:24 -0700, Samuel Sieb wrote: > > > > Oh, right. I never use a regexp that can match nothing, so I missed >

Re: sed regex oddness

2016-05-05 Thread Rick Stevens
On 05/05/2016 08:56 AM, Samuel Sieb wrote: On 05/05/2016 03:35 AM, Ian Malone wrote: On 5 May 2016 at 10:27, Patrick O'Callaghan wrote: On Wed, 2016-05-04 at 16:24 -0700, Samuel Sieb wrote: Oh, right. I never use a regexp that can match nothing, so I missed that. :-) You never use '*'? I

Re: sed regex oddness

2016-05-05 Thread Samuel Sieb
On 05/05/2016 10:11 AM, Rick Stevens wrote: On 05/05/2016 08:56 AM, Samuel Sieb wrote: On 05/05/2016 03:35 AM, Ian Malone wrote: On 5 May 2016 at 10:27, Patrick O'Callaghan wrote: On Wed, 2016-05-04 at 16:24 -0700, Samuel Sieb wrote: Oh, right. I never use a regexp that can match nothing, s

Re: sed regex oddness

2016-05-05 Thread Patrick O'Callaghan
On Thu, 2016-05-05 at 10:31 -0700, Samuel Sieb wrote: > On 05/05/2016 10:11 AM, Rick Stevens wrote: > > > > On 05/05/2016 08:56 AM, Samuel Sieb wrote: > > > > > > On 05/05/2016 03:35 AM, Ian Malone wrote: > > > > > > > > On 5 May 2016 at 10:27, Patrick O'Callaghan > > > com> > > > > wrote: > >

Re: sed regex oddness

2016-05-05 Thread Samuel Sieb
On 05/05/2016 01:47 PM, Patrick O'Callaghan wrote: On Thu, 2016-05-05 at 10:31 -0700, Samuel Sieb wrote: On 05/05/2016 10:11 AM, Rick Stevens wrote: On 05/05/2016 08:56 AM, Samuel Sieb wrote: On 05/05/2016 03:35 AM, Ian Malone wrote: On 5 May 2016 at 10:27, Patrick O'Callaghan wrote: On

Re: sed regex oddness

2016-05-05 Thread Tim
Allegedly, on or about 05 May 2016, Samuel Sieb sent: > Yes, that's what I meant. I can't imagine where that would even be > useful. Matching nothing? Testing for a null response. -- [tim@localhost ~]$ uname -rsvp Linux 3.9.10-100.fc17.x86_64 #1 SMP Sun Jul 14 01:31:27 UTC 2013 x86_64 Boilerp

Re: sed regex oddness

2016-05-05 Thread Patrick O'Callaghan
On Thu, 2016-05-05 at 13:56 -0700, Samuel Sieb wrote: > > I fail to see what's odd about it. When you match something with an > > optional part it's completely normal. > > > Thank you for making my point once again... > This is about the case where the entire regexp will match the empty > string!