Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14736
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: reg expression |
| Date | 2012-06-27 19:38 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <q1gnu759m1k9lbf8jdqqcam93edn4csn82@4ax.com> (permalink) |
| References | <jsfv2r$sks$1@speranza.aioe.org> |
On Wed, 27 Jun 2012 17:48:15 -0400, "phil hunt" <a@abc.com> wrote:
>In Jsctipt, I have
>
>re = new RegExp("one|two", "gi");
>
>"one three".search(re); return an integer >-1, meaning it found a match
>
>My question is how do I set up the RegExp to match "one" AND "two". I though
>an & would do it, but no.
If you mean that the string contains both "one" and "two", the
regex would be
one.*two|two.*one
Warning: "." does not match newline. It does match any other
character.
This approach is not workable if you have many terms as the
complexity of the expression is O(n!). For three terms, there would
be six alternatives. For four, 24.
Sincerely,
Gene Wirchenko
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
reg expression "phil hunt" <a@abc.com> - 2012-06-27 17:48 -0400
Re: reg expression Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2012-06-27 23:55 +0200
Re: reg expression Dr J R Stockton <reply1226@merlyn.demon.co.uk.not.invalid> - 2012-06-28 19:08 +0100
Re: reg expression Spamless <Spamless@Nil.nil> - 2012-06-29 08:22 -0500
Re: reg expression "Phil Hunt" <aaa@aaa.com> - 2012-06-29 10:19 -0400
Re: reg expression Spamless <Spamless@Nil.nil> - 2012-06-29 11:36 -0500
Re: reg expression Gene Wirchenko <genew@ocis.net> - 2012-06-29 10:05 -0700
Re: reg expression Gene Wirchenko <genew@ocis.net> - 2012-06-27 19:38 -0700
Re: reg expression Gene Wirchenko <genew@ocis.net> - 2012-06-27 21:18 -0700
Re: reg expression "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-28 06:24 +0000
Re: reg expression Spamless <Spamless@Nil.nil> - 2012-06-28 05:36 -0500
Re: reg expression "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-28 15:15 +0000
Re: reg expression "Phil Hunt" <aaa@aaa.com> - 2012-06-28 12:08 -0400
csiph-web