View Single Post
Old 11-17-2010, 07:00 PM   #150
Happy Monkey
I think this line's mostly filler.
 
Join Date: Jan 2003
Location: DC
Posts: 13,575
I was using unix's regex (I tested using sed).

The ^ is to denote the beginning of the line.
the " *" is to include spaces. If you have tabs as well, you'd need [xy]*, where x is a space and y is a tab.
The [01-9]* catches zero or more digits. I had the leading zero because I wasn't sure whether zero was actually first in ASCII, so I included it separately from the range. It is first, so [0-9]* would work. To make sure you don't get blank lines, it probably should be [1-9][0-9]*. The first brackets are one digit, and the second are zero or more additional digits.
Then another " *" for trailing spaces.
And a \$ for the end of the line. The $ is the symbol, but I need to escape it with the backslash so it doesn't get parsed by my command line.

An updated version could be:
Code:
^[  ]*[1-9][0-9]*[  ]*\$
If the syntax is different in your app, the pattern is:
Code:
(beginning of line marker)[whitespace characters]*[1-9][0-9]*[whitespace characters]*(end of line marker)
__________________
_________________
|...............| We live in the nick of times.
| Len 17, Wid 3 |
|_______________| [pics]
Happy Monkey is offline   Reply With Quote