Page 1 of 1

Double letters?

Posted: Sun May 13, 2012 1:51 am
by dfhtextpipe
Hi Simon,

Is there an easy method to search for double letters?

David

Re: Double letters?

Posted: Mon May 14, 2012 12:55 pm
by DataMystic Support
Yes David,

Just use a perl pattern of

Code: Select all

([a-z])\1

Re: Double letters?

Posted: Tue May 15, 2012 12:31 am
by dfhtextpipe
Did you understand my question?

I want a simple method to find double letters, not just two letters that may or may not be the same.

(aa|bb|cc|dd ... |xx|yy|zz) would do it, but there must be a shorter pattern, surely.

David

Re: Double letters?

Posted: Tue May 15, 2012 8:31 am
by DataMystic Support
Hi David,

[a-z]{2} will find two letters, what I wrote first does in fact work!

Re: Double letters?

Posted: Wed May 16, 2012 1:53 am
by dfhtextpipe
How amazing!

I'm still struggling to understand how it does work.

Code: Select all

000084	aa
000018	ee
000406	ii
000021	oo
000009	ss
000009	uu
000223	vv
David

Re: Double letters?

Posted: Wed May 16, 2012 8:32 am
by DataMystic Support
\1, \2 etc in perl parlance refer to the previously matched text in captured sub-pattern 1, 2 etc.