[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: REGEX question



On Mon, Jan 21, 2002 at 05:07:21PM -0500, Alec wrote:
> Hi
> 
> How can I match the same character repeated n times?
> ".{n}" matches any n characters.

You want to remember the first character and match the same using a
backreference. In grep:

	\(.\)\1

In egrep, perl, or ruby:

	(.)\1

-- 
Henry House
The attached file is a digital signature. See <http://romana.hajhouse.org/pgp>
for information.  My OpenPGP key: <http://romana.hajhouse.org/hajhouse.asc>.

Attachment: pgpeE3zT10aWD.pgp
Description: PGP signature


Reply to: