Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27055 > unrolled thread
| Started by | "Tony Johansson" <johansson.andersson@telia.com> |
|---|---|
| First post | 2015-03-15 22:25 +0100 |
| Last post | 2015-03-15 23:40 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.javascript
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
| From | "Tony Johansson" <johansson.andersson@telia.com> |
|---|---|
| Date | 2015-03-15 22:25 +0100 |
| Subject | Regular expression |
| Message-ID | <me4tbi$iiu$1@dont-email.me> |
Can somebody explain this regular expression
document.getElementById('rovarsprak').value.replace(/([bcdfghjklmnpqrstvwxz])o\1/gi,
'$1');
//tony
[toc] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-03-15 21:38 +0000 |
| Message-ID | <877fuindpx.fsf@bsb.me.uk> |
| In reply to | #27055 |
"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.
[toc] | [prev] | [next] | [standalone]
| From | Cezary Tomczyk <cezary.tomczyk@gmail.com> |
|---|---|
| Date | 2015-03-15 23:40 +0100 |
| Message-ID | <5bb50$55060a4f$6def49d7$18889@nntpswitch.blueworldhosting.com> |
| In reply to | #27055 |
On 2015-03-15 22:25, Tony Johansson wrote:
> Can somebody explain this regular expression
> document.getElementById('rovarsprak').value.replace(/([bcdfghjklmnpqrstvwxz])o\1/gi,
> '$1');
The other way (apart of Ben's explanation) to explain that (and others
as well) regular expression might be to use nice tool:
https://regex101.com/r/qR9nN4/1
--
Cezary Tomczyk
http://www.ctomczyk.pl/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web