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


Groups > comp.lang.javascript > #27056

Re: Regular expression

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Regular expression
Date 2015-03-15 21:38 +0000
Organization A noiseless patient Spider
Message-ID <877fuindpx.fsf@bsb.me.uk> (permalink)
References <me4tbi$iiu$1@dont-email.me>

Show all headers | View raw


"Tony Johansson" <johansson.andersson@telia.com> writes:

> Can somebody explain this regular expression
<snip> 
  replace(/([bcdfghjklmnpqrstvwxz])o\1/gi, '$1');

Match any one of bcdfghjklmnpqrstvwxz -- that's what the []s mean.
I.e. match a single non-vowel (taking y to be a vowel too).

Remember this matched letter -- that's what the ()s mean.

Match a single 'o'.

Match the non-vowel seen before -- that's what the \1 means.

Do this globally (i.e. repeat for very match) -- that's the 'g' -- and
ignoring case -- that's the 'i'.

For every such match, replace it with the single-letter non-vowel.  '$1'
in a replacement string means the first captured match.

-- 
Ben.

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


Thread

Regular expression "Tony Johansson" <johansson.andersson@telia.com> - 2015-03-15 22:25 +0100
  Re: Regular expression Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-03-15 21:38 +0000
  Re: Regular expression Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-03-15 23:40 +0100

csiph-web