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


Groups > comp.lang.javascript > #39253

Re: string function doesn't have array functions

Path csiph.com!weretis.net!feeder8.news.weretis.net!news.mb-net.net!open-news-network.org!.POSTED.96.235.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: string function doesn't have array functions
Date Mon, 07 Dec 2020 23:35:05 +0100
Organization PointedEars Software (PES)
Lines 23
Message-ID <4278291.LvFx2qVVIh@PointedEars.de> (permalink)
References <6cf898b5-74a5-43fa-b382-e765287d65d2n@googlegroups.com> <9c34e490-04fd-49a5-8ab5-ff2ba9f0684en@googlegroups.com> <435c57e1-7ae0-4506-8d38-8560bca6f2dan@googlegroups.com> <0fdd8034-346a-420a-acaa-ae832f2a88acn@googlegroups.com> <e0fc4d1f-6294-40c1-81f8-d9753c383a47n@googlegroups.com> <41bac879-f5a8-4099-88ff-f8003fbc1de5n@googlegroups.com>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
Injection-Info gwaiyur.mb-net.net; posting-host="96.235.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch:178.197.235.96"; logging-data="23826"; mail-complaints-to="abuse@open-news-network.org"
User-Agent KNode/4.14.10
Cancel-Lock sha1:xyHD8AVcsOjsI/szMzk/ph1den4=
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
X-User-ID U2FsdGVkX18aK8bwEr53v+mt4/85rpmLaXl1tDd/rP7OWSlcgmuCzg==
Xref csiph.com comp.lang.javascript:39253

Show key headers only | View raw


Michael Haufe (TNO) wrote:

> If you already have the full string replacing it is straightforward
> enough:
> 
> ```
> let cookieData =
> 'SSOD-SAT=AFX1AAAAYABvr;s_cc=true;TLTSID=F4FAF40;XSRF-
                         ^         ^
> TOKEN=D9CF17822CDCA3D8337DE8F4485EA912';
> cookieData = cookieData.replace(/XSRF-TOKEN=(.+)\b/,($0,$1) =>
> `XSRF-TOKEN=000123456`) ```

This replacement will, in general, *obviously* NOT work as expected, as 
cookies’ key–value pairs are separated by semicolon, and .+ is greedy.
And there is no need for capturing the old value or for the callback here.

Use .replace(/((?:^|;\s*)XSRF-TOKEN)=[^;]+/, "$1=000123456") instead.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

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


Thread

string function doesn't have array functions JRough <janis.rough@gmail.com> - 2020-12-07 07:54 -0800
  Re: string function doesn't have array functions Julio Di Egidio <julio@diegidio.name> - 2020-12-07 08:30 -0800
    Re: string function doesn't have array functions JRough <janis.rough@gmail.com> - 2020-12-07 09:15 -0800
      Re: string function doesn't have array functions "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-12-07 10:06 -0800
        Re: string function doesn't have array functions JRough <janis.rough@gmail.com> - 2020-12-07 10:28 -0800
          Re: string function doesn't have array functions "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-12-07 11:33 -0800
            Re: string function doesn't have array functions Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-12-07 23:35 +0100
              Re: string function doesn't have array functions "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-12-07 14:36 -0800
              Re: string function doesn't have array functions JRough <janis.rough@gmail.com> - 2020-12-07 15:29 -0800
  Re: string function doesn't have array functions "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-12-07 09:53 -0800

csiph-web