Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33340
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2017-05-17 15:16 -0700 |
| References | (1 earlier) <2onjgctpq57a8vqa6i0jp42t58ols8n9rt@4ax.com> <28d725b0-3f1a-4af6-917f-1f8442dd08a6@googlegroups.com> <XnsA778C7363C1D5eejj99@194.109.6.166> <bc377153-c2e8-4aa0-8a6d-318c3b65f6b1@googlegroups.com> <XnsA778D11179439eejj99@194.109.6.166> |
| Message-ID | <69e3d1ac-e112-436d-939a-e8736940927a@googlegroups.com> (permalink) |
| Subject | Re: How to perform an EXACT match for an item without looping through? |
| From | justaguy <lichunshen84@gmail.com> |
On Wednesday, May 17, 2017 at 2:33:13 PM UTC-4, Evertjan. wrote:
> justaguy wrote on 17 May 2017 in
> comp.lang.javascript:
>
> >> Did not follow the thread,
> >> but in general change the regex
> >>
> >> var f = list.match(/123ab45/g);
> >>
> >> to
> >>
> >> var f = list.match(/123ab45/ig);
> >>
> >
> > Ok, I've made such change except I used
> > var e = document.getElementById('myID').value;
> > then set f = list.match(/e/ig);
> > And when e (element value is "123ab45"), returned f is still null, how
> > come?
> >
>
> You cannot use a js-variable e in a regex string,
> at least not this way:
>
> var e = document.getElementById('myID').value;
> var f = list.match(/e/ig);
>
> better try:
>
> var e = document.getElementById('myID').value;
> var re = new RegExp( e,'ig' );
> var f = list.match(re);
>
It still fails. I've decided to loop through the values since it's a small loop anyway. Thanks tho.
> Regex is very powerfull, but it is not guesswork, read the specs.
>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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