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


Groups > comp.lang.javascript > #36683 > unrolled thread

Remove all lines where first character is not a digit.

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2019-05-30 13:41 -0700
Last post2019-06-01 02:44 -0700
Articles 6 on this page of 26 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

Page 2 of 2 — ← Prev page 1 [2]


#36723

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-06-01 02:14 -0700
Message-ID<33e55e30-e4ef-41cd-bacb-5f0a2041a65d@googlegroups.com>
In reply to#36721
Den lördag 1 juni 2019 kl. 10:55:54 UTC+2 skrev Jonas Thörnvall:
> Den lördag 1 juni 2019 kl. 09:45:21 UTC+2 skrev Luuk:
> > On 1-6-2019 09:07, Jonas Thörnvall wrote:
> > 
> > > 
> > > Actually i am thinking of replacing regex in code with string functions, they make sense and do not need to be commented.
> > > 
> > > 
> > 
> > Good luck with doing that, and i would like to see the results of this 
> > piece if javascript in code with string functions. (Just for learning 
> > puposes, of 'how-to-do-it-the-other-way')
> > 
> > let source = "1 qwerty\n2 asdfg\nqweeee\n4 z"
> > let result = source.replace(/^[^0-9].*\n/gm, '');
> > 
> > 
> > 
> > -- 
> > Luuk
> 
> In principle this should work but i am terrible with the syntax so... It doesn't now i showed "the other way", can you show med where it go wrong becaues apparently my splice do not remove the lines.

Oops forgot to post the code, i found the error must think of howto remove it not the first time i tried to splice within a loop....

[toc] | [prev] | [next] | [standalone]


#36724

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-06-01 02:38 -0700
Message-ID<7da949c0-0e1d-442b-8a60-84bf5a9d571d@googlegroups.com>
In reply to#36716
Den lördag 1 juni 2019 kl. 09:45:21 UTC+2 skrev Luuk:
> On 1-6-2019 09:07, Jonas Thörnvall wrote:
> 
> > 
> > Actually i am thinking of replacing regex in code with string functions, they make sense and do not need to be commented.
> > 
> > 
> 
> Good luck with doing that, and i would like to see the results of this 
> piece if javascript in code with string functions. (Just for learning 
> puposes, of 'how-to-do-it-the-other-way')
> 
> let source = "1 qwerty\n2 asdfg\nqweeee\n4 z"
> let result = source.replace(/^[^0-9].*\n/gm, '');
> 
> 
> 
> -- 
> Luuk

I am not sure i am not able to remove last line "empty" of last bank. File is in other post. I can see i find it and the charCode is 13 so it should be remove with splice but...

function ListBankInstruments(current){
	instName=Abank[current].split("\n");[]
	//REMOVE FIRST LINE "BANKNAME"
	instName.shift();
	//REMOVE LINES NOT STARTING WITH DIGIT OR EMPTY
	alert(instName[instName.length-1].charCodeAt(0));
	
	for (var j=instName.length-1;j>=0;j--){
   	ChCode=instName[j].charCodeAt(0);
	if (ChCode<48 || ChCode>57 || ChCode==13 ) { instName.splice(j,1); }
	}
	alert(instName.length);
	instOptionList();
}

[toc] | [prev] | [next] | [standalone]


#36695

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-05-31 00:35 -0700
Message-ID<396b0cff-d144-4cdf-819c-670f68ba2669@googlegroups.com>
In reply to#36690
Den fredag 31 maj 2019 kl. 09:17:42 UTC+2 skrev Evertjan.:
> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 31 May 
> 2019 in comp.lang.javascript:
> 
> > I just tried it i don't think it work the ; "line"
> > and the --------- line still there at end of last bank N364 combi D
> 
> See, you are using code you don't understand!
> 
> I warned you against that, 
> specifying that my code was for learning and understanding, 
> not for blind application. 
> 
> However you may be quite right in your assessment,
> that you don't think. 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Well i think enough to be able to create linked option lists dynamically from a textfile without creating an object. "That require some IQ" contrary  parroting the symbolic shortsyntax in regexp, that as a tool was outdated in early 70's.

Your comments are pitiful at best LoL

[toc] | [prev] | [next] | [standalone]


#36697

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2019-05-31 09:41 +0200
Message-ID<XnsAA6062849DF0Aeejj99@194.109.6.166>
In reply to#36695
<jonas.thornvall@gmail.com> wrote on 31
May 2019 in comp.lang.javascript: 

> Well i think enough to be able to create linked option lists dynamically
> from a textfile without creating an object. 

Look mamma, no hands!

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#36720

FromJJ <jj4public@vfemail.net>
Date2019-06-01 15:29 +0700
Message-ID<6khd26r9l6g6.16i61rgoczt8m.dlg@40tude.net>
In reply to#36683
On Thu, 30 May 2019 13:41:25 -0700 (PDT), Jonas Thörnvall wrote:
> 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.

If `Abank[current]` contains multiple lines, use this.

  Abank[current].replace(/^[^\d][^\n]*\n|\n[^\d][^\n]*|^[^\d][^\n]*$/g, "");

But if `Abank[current]` contains an extracted line of a multiline string,
then you're doing the filtering at the wrong point.

[toc] | [prev] | [next] | [standalone]


#36725

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-06-01 02:44 -0700
Message-ID<348d734b-40bc-4b50-82ba-2849973bb55c@googlegroups.com>
In reply to#36720
Den lördag 1 juni 2019 kl. 10:29:44 UTC+2 skrev JJ:
> On Thu, 30 May 2019 13:41:25 -0700 (PDT), Jonas Thörnvall wrote:
> > 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.
> 
> If `Abank[current]` contains multiple lines, use this.
> 
>   Abank[current].replace(/^[^\d][^\n]*\n|\n[^\d][^\n]*|^[^\d][^\n]*$/g, "");
> 
> But if `Abank[current]` contains an extracted line of a multiline string,
> then you're doing the filtering at the wrong point.

Well i think it was better solved with string functions JJ.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.javascript


csiph-web