Page 1 of 1

Regular expression: specifying line length

Posted: Tue Jul 22, 2003 11:06 am
by miraclemaker
Hi, I'm trying to define a regular expression that will match entire lines that are below a certain length. I know how to specify that a whole line must be matched, and that the line can contain any characters, but I'm having trouble with spcifying the length part - can anyone help?

Thanks.

Posted: Tue Jul 22, 2003 12:01 pm
by bveldkamp
This will select lines having 15 or less characters (leave out the slashes if you have posix RE syntax enabled):
^.\{0,15\}$

Berend

Posted: Tue Jul 22, 2003 12:17 pm
by miraclemaker
That's great - thanks!

I was getting close - this is as far as I got:
^\(.\{0,5\}\)$