Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39256
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2020-12-07 15:29 -0800 |
| References | (2 earlier) <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> <4278291.LvFx2qVVIh@PointedEars.de> |
| Message-ID | <e53d8077-e1ad-4e24-a703-7393bc4e4679n@googlegroups.com> (permalink) |
| Subject | Re: string function doesn't have array functions |
| From | JRough <janis.rough@gmail.com> |
On Monday, December 7, 2020 at 2:35:15 PM UTC-8, Thomas 'PointedEars' Lahn wrote: > 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. very awesome Regex. thanks,
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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