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


Groups > comp.lang.javascript > #36632

Re: indexOf do not behave as i expected?

Newsgroups comp.lang.javascript
Date 2019-05-22 04:26 -0700
References <21c9b272-81ba-4da2-9c25-378447e0d635@googlegroups.com> <XnsAA578086F3284eejj99@194.109.6.166>
Message-ID <50b1cfeb-b508-4be4-9986-8bd32d39bcf0@googlegroups.com> (permalink)
Subject Re: indexOf do not behave as i expected?
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


Den onsdag 22 maj 2019 kl. 12:38:11 UTC+2 skrev Evertjan.:
> Jonas_Thornvall <jonas.thornvall@gmail.com> wrote on 22 May 2019 in 
> comp.lang.javascript:
> 
> >      while(!LASTBANK) {
> >             var bnkSTART = ATXT.indexOf("[",LB);
> >             var bnkEND = ATXT.indexOf("]",LB);
> > 
> 
> Time to learn Regex!
> 
> <script> 
> 
> 'use strict';
> 
> let s = '[blah1] blah2 [blah3] blah4 [blah5] blah6' ;
> 
> let rgx = /\[(.*?)\]/g;
> 
> let matches;
> 
> let output = [];
> 
> while (matches = rgx.exec(s)) {
>     output.push(matches[1]);
> };
> 
> console.log(output);
> 
> // Array(3)
> // 0: "blah1"
> // 1: "blah3"
> // 2: "blah5"
> // length: 3
> 
> </script> 
> 
> 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

If i wanted to replace the closing paragraph with a newline "get full content after ["?

let rgx = /\[(.*?)\'/n'/g; 

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


Thread

indexOf do not behave as i expected? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-22 02:38 -0700
  Re: indexOf do not behave as i expected? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-22 12:38 +0200
    Re: indexOf do not behave as i expected? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-22 03:53 -0700
    Re: indexOf do not behave as i expected? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-22 04:26 -0700
      Re: indexOf do not behave as i expected? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-22 04:38 -0700
        Re: indexOf do not behave as i expected? JJ <jj4public@vfemail.net> - 2019-05-22 19:34 +0700
          Re: indexOf do not behave as i expected? Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-05-22 13:48 +0000
    Re: indexOf do not behave as i expected? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-05-22 22:28 +0200
  Re: indexOf do not behave as i expected? "R.Wieser" <address@not.available> - 2019-05-23 07:59 +0200
    Re: indexOf do not behave as i expected? "R.Wieser" <address@not.available> - 2019-05-23 10:47 +0200

csiph-web