Page 1 of 1

Matching line numbers

Posted: Mon Mar 08, 2010 9:29 pm
by SteveH
Is there a nice, elegant regular expression that matches all the following line numbers. They all start as the first character on a new line and the one without the 'E have a space in front of them.

Code: Select all

 000000
     25
     30
    100
 500000
E700000
 999999

Posted: Mon Mar 08, 2010 9:43 pm
by ben_josephs
Is this what you need?
Find what: ^( +|E)[0-9]+

[X] Regular expression
It assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax

Posted: Mon Mar 08, 2010 9:58 pm
by SteveH
It assumes you are using Posix regular expression syntax
Thanks Ben, that works great as always.

In this case it's something closer to PCRE.

Posted: Tue Mar 09, 2010 12:26 am
by Bob Hansen
Here is another solution also:

Search for: ^.{7}

Posted: Tue Mar 09, 2010 8:18 am
by SteveH
Thanks Bob. That would also match the first 7 characters of comments, which can also occupy the same space as statement numbers. I didn't say that though, so your suggestion would work on the example I provided.