Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #36687

Re: Remove all lines where first character is not a digit.

Newsgroups comp.lang.javascript
Date 2019-05-30 23:18 -0700
References <9ff34af1-9e27-4f78-b686-990dcea4371d@googlegroups.com> <XnsAA60EA3F293eejj99@194.109.6.166>
Message-ID <475c9700-1982-4295-8d95-0b9bbdc299d2@googlegroups.com> (permalink)
Subject Re: Remove all lines where first character is not a digit.
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


Den fredag 31 maj 2019 kl. 00:05:31 UTC+2 skrev Evertjan.:
> <jonas.thornvall@gmail.com> wrote on 30 May 2019 in comp.lang.javascript: 
> 
> > Abank[current].replace(/^\s*[\r]/gm,"");
> > 
> > Well this remove something else.
> > 
> > But i saw someone saying that this should remove and line not starting
> > with digit? ^[^0-9].*
> > 
> > It did not say what language regexp or engine the expression was for.
> > 
> > But how can i apply the ^[^0-9].* to do a replace like string at top.
> 
> let source = "1 qwerty\n2 asdfg\nqweeee\n4 z"
> let result = source.replace(/^[^0-9].*\n/gm, '');
> 
> PLEASE for your own good, analyze this, not just use it!
> 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

To be honest Jan there is notthing to analyse, it is just a rather contrieved shortsyntax a bit like hieroglyphs. If i had made regexp it probably would had made sense for anyone looking at the expression. 

Well i can see that see that we look for any value between 0 and 9, i can only guess that ^/ means we are at char 1, "could been done better" i think you also have something about newline in there and /gm "have no idea.

But my analyse and conclusion is, i could do a beter semantic for regexp, one that possibly would "be a bit longer to write out". But people had no problem what so ever to decode. Because for this one you need a lookup table LoL

"Honestly Everjan i really could make something better, and i think it would be much more general using far fewer syntactical elements, and in my regexp the *hieroglyphs* actually would made sense"

That aside i understand that regexp was created during a time when the resources on a computer were in short, and one wanted to save space "but that argument does not hold when you implement something like this today". But maybe one wanted to keep it simple for people that once learned SED under unix. But is that really a valid argument?

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-30 13:41 -0700
  Re: Remove all lines where first character is not a digit. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 00:05 +0200
    Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-30 23:18 -0700
      Re: Remove all lines where first character is not a digit. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 09:10 +0200
    Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-30 23:38 -0700
      Re: Remove all lines where first character is not a digit. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 09:17 +0200
        Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-31 00:25 -0700
          Re: Remove all lines where first character is not a digit. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 09:39 +0200
            Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-31 04:47 -0700
            Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-31 04:55 -0700
              Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-31 05:01 -0700
              Re: Remove all lines where first character is not a digit. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 15:43 +0200
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-31 09:16 -0700
                Re: Remove all lines where first character is not a digit. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-06-01 00:29 +0200
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 00:07 -0700
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 00:22 -0700
                Re: Remove all lines where first character is not a digit. Luuk <luuk@invalid.lan> - 2019-06-01 09:45 +0200
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 00:53 -0700
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 01:01 -0700
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 01:55 -0700
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 02:14 -0700
                Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 02:38 -0700
        Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-31 00:35 -0700
          Re: Remove all lines where first character is not a digit. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 09:41 +0200
  Re: Remove all lines where first character is not a digit. JJ <jj4public@vfemail.net> - 2019-06-01 15:29 +0700
    Re: Remove all lines where first character is not a digit. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 02:44 -0700

csiph-web