Page 1 of 1

Can't find character

Posted: Mon Apr 23, 2012 9:27 pm
by gcotterl
To find lines with a hyphen in position 97, I type:

^.{96}-

in the 'Find What' box, tick "Regular Expression" then click "Find All" but a dialog box is displayed saying "Cannot find regular expression: '^.{96}-'

(In the Preferences Edit menu. the "Use POSIX regular expression syntax" box is ticked).

Is there something "special" about searching for a hyphen?

Posted: Mon Apr 23, 2012 9:45 pm
by ben_josephs
No, there isn't. Hyphen is "special" only when enclosed in square brackets.

Are you sure the character position is correct? Are you sure it's a hyphen?

Posted: Mon Apr 23, 2012 10:12 pm
by gcotterl
[b][size=18]CORRECTION[/size].[/b]

To find lines with a hyphen in position 93, I type:

^.{92}-


Here are some examples of my data:

009601705-4
008514276-7
008516513-7
009701511-4
009600208-9

(The character before each hyphen is in positon 92).

Posted: Mon Apr 23, 2012 10:15 pm
by ben_josephs
You are using "Posix" regular expression syntax, aren't you?

Posted: Mon Apr 23, 2012 10:18 pm
by gcotterl
Yes, in the Preferences Edit menu. the "Use POSIX regular expression syntax" box is ticked

Posted: Mon Apr 23, 2012 10:40 pm
by gcotterl
I found the problem: At the beginning of each line, there was a tab character.

Subtracting the number of positions represented by the tab character from the number in my original regular expression resulted in successful "finds".