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


Groups > comp.lang.javascript > #33229

Re: How to perform an EXACT match for an item without looping through?

Path csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: How to perform an EXACT match for an item without looping through?
Date Sat, 06 May 2017 02:10:06 +0200
Organization PointedEars Software (PES)
Lines 38
Message-ID <11781939.dW097sEU6C@PointedEars.de> (permalink)
References <5cc88464-96fb-45b6-b2ba-7b5e4f1d9a83@googlegroups.com> <1pmay28c1l3i8.1skar79uhfbmu.dlg@40tude.net> <bf940060-7596-4738-82ae-fc7287be47de@googlegroups.com> <list-20170503140714@ram.dialup.fu-berlin.de> <3688698.1IzOArtZ34@PointedEars.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1494029406 14530 eJwNy8ERwDAIA8GWAkIiLgc7pv8Swtxz5wiZToaoYE+7mm+gn8XaDBNcn18lcD3Hw+xUNe4Mq38SVhDT (6 May 2017 00:10:06 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Sat, 6 May 2017 00:10:06 +0000 (UTC)
User-Agent KNode/4.14.2
Cancel-Lock sha1:M/+Sai7lwGeBMRZj/anK2FDbgD0=
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-NNTP-Posting-Host eJwFwYEBwCAIA7CXLLSA5yiO/09YIg9EJ0NBjYYtM8eo0H5ecj/hC6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com comp.lang.javascript:33229

Show key headers only | View raw


Thomas 'PointedEars' Lahn wrote:

> Stefan Ram wrote:
>> justaguy <lichunshen84@gmail.com> writes:
>>>Sorry, it must be a misunderstanding.  For instance,
>>>list.indexOf('12345') produces "found", which is wrong
>>>because it's not the same as '123456', the latter is an item
>>>from the list while the '12345' is not.
>> 
>>   So, maybe, you're looking for
>> 
>> f=(x,y)=>new RegExp(",([^,]*"+y+"[^,]*),").exec(","+x+",")[1];
   ^ ^^^^^^^            ^ ^^^^^  ^            ^^^^^^^^^^^^^^^
 [1] [2]               [3] [6]  [4]           [5][6]

>> f("abcdefghi,jklmnopqrst,uvwxyz","mno")=="jklmnopqrst";
>> 
>>   then?
> 
> Good grief.

To elaborate, this is (from left to right)

  · error-prone[^1]
  · unnecessarily incompatible[^2]
  · unnecessarily unreadable (hard to maintain)[^2][^4]
  · insufficient[^3]
  · unsafe[^4]
  · unnecessarily complicated[^5]
  · unnecessarily inefficient[^6]

IOW: Just. DO. NOT. Do. This.  Ever.

-- 
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

How to perform an EXACT match for an item without looping through? justaguy <lichunshen84@gmail.com> - 2017-05-02 18:49 -0700
  Re: How to perform an EXACT match for an item without looping through? JJ <jj4public@vfemail.net> - 2017-05-03 18:36 +0700
    Re: How to perform an EXACT match for an item without looping through? justaguy <lichunshen84@gmail.com> - 2017-05-03 05:58 -0700
      Re: How to perform an EXACT match for an item without looping through? JJ <jj4public@vfemail.net> - 2017-05-04 15:03 +0700
        Re: How to perform an EXACT match for an item without looping through? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-05-04 10:57 +0200
        Re: How to perform an EXACT match for an item without looping through? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 18:40 +0200
      Re: How to perform an EXACT match for an item without looping through? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 19:59 +0200
        Re: How to perform an EXACT match for an item without looping through? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-06 02:10 +0200
  Re: How to perform an EXACT match for an item without looping through? John G Harris <niam@jghnorth.org.uk.invalid> - 2017-05-03 14:45 +0100
    Re: How to perform an EXACT match for an item without looping through? justaguy <lichunshen84@gmail.com> - 2017-05-03 07:12 -0700
    Re: How to perform an EXACT match for an item without looping through? justaguy <lichunshen84@gmail.com> - 2017-05-17 09:58 -0700
      Re: How to perform an EXACT match for an item without looping through? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-05-17 19:34 +0200
        Re: How to perform an EXACT match for an item without looping through? justaguy <lichunshen84@gmail.com> - 2017-05-17 11:12 -0700
          Re: How to perform an EXACT match for an item without looping through? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-05-17 20:33 +0200
            Re: How to perform an EXACT match for an item without looping through? justaguy <lichunshen84@gmail.com> - 2017-05-17 15:16 -0700
              Re: How to perform an EXACT match for an item without looping through? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-05-18 11:15 +0200
                Re: How to perform an EXACT match for an item without looping through? justaguy <lichunshen84@gmail.com> - 2017-05-19 07:58 -0700

csiph-web