Find
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Code: Select all
Find what ^.{57}\.
[X] Regular Expression
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
The general form would be
where N is the position.
Note, you must do the math and not put 58-1 or 23-1
Code: Select all
Find what ^.{N-1}\.
Note, you must do the math and not put 58-1 or 23-1
I choose to fight with a sack of angry cats.
Find
I re-read the postings and noticed the reference to "POSIX regular expressions assumed".
I clicked on CONFIGURE/PREFERENCES/EDITOR and clicked on "Use POSIX regular expressions syntax".
It's now working!!
Thanks loads! This will save me many hours of work!!
I clicked on CONFIGURE/PREFERENCES/EDITOR and clicked on "Use POSIX regular expressions syntax".
It's now working!!
Thanks loads! This will save me many hours of work!!
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
That was a slip.
It should be
In your case:
This assumes you are using Posix regular expression syntax:
It should be
where N is one less than the column position.Find what: ^.{N},
[X] Regular expression
In your case:
In the search text, when you are searching using a regular expression, a simple dot ( . ) represents any single character (except newline); a quoted dot ( \. or [.] ) represents a literal dot.Find what: ^.{22},
[X] Regular expression
This assumes you are using Posix regular expression syntax:
Configuration | Preferences | Editor
[X] Use POSIX regular expression syntax
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Re: Find
In this example, it's just the braces ( {...} ) that are affected. The meanings of {...} and \{...\} are swapped.gcotterl wrote:"Use POSIX regular expressions syntax"
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Hi Ben,
It looks like the character that I want to find follows the ^
So:
To find a dash, the entry would be: ^-{N},
To find an "BC", the entry would be: ^BC{N},
To find any single character (except newline), the entry would be: ^.{N},
To find a literal dot, the entry would be" ^\.{N}, or ^[.]{N},
correct?
I don't know what you mean by "In this example, it's just the braces
( {...} ) that are affected. The meanings of {...} and \{...\} are swapped).
It looks like the character that I want to find follows the ^
So:
To find a dash, the entry would be: ^-{N},
To find an "BC", the entry would be: ^BC{N},
To find any single character (except newline), the entry would be: ^.{N},
To find a literal dot, the entry would be" ^\.{N}, or ^[.]{N},
correct?
I don't know what you mean by "In this example, it's just the braces
( {...} ) that are affected. The meanings of {...} and \{...\} are swapped).
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
No. To find lines with a hyphen in position 77, you need: ^.{76}-
To find lines with a dot in position 77, you need: ^.{76}\.
By "The meanings of {...} and \{...\} are swapped" I meant that they have opposite meanings in Posix and non-Posix syntax.
Edit: Added missing hyphen in last line of explanation.
Code: Select all
^ beginning of a line
. any character
.{76} any character, 76 times; i.e., any 76 characters
^.{76} any 76 characters at the beginning of a line
- a hyphen
^.{76}- any 76 characters at the beginning of a line, followed by a hyphen
By "The meanings of {...} and \{...\} are swapped" I meant that they have opposite meanings in Posix and non-Posix syntax.
Edit: Added missing hyphen in last line of explanation.
Last edited by ben_josephs on Tue Mar 21, 2006 4:34 pm, edited 1 time in total.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
I think that a more effective way for you to learn how to use regular expressions might be for you to try to understand how they are constructed, rather than repeatedly relying on others to give you a new expression each time there is a small change in your requirements.
If there is anything in the explanation I gave earlier that is not clear, please let me know, and I will try to express it more carefully.
If there is anything in the explanation I gave earlier that is not clear, please let me know, and I will try to express it more carefully.
Find
(I'm sorry for the questions but I just want to understand the syntax of the expression so I can use it correctly).
Your previous posting says:
To find lines with a hyphen in position 77, you need: ^.{76}-
To find lines with a dot in position 77, you need: ^.{76}\.
So, I was correct in saying that "the character I want to find follows the last brace (instead of the ^)".
In your second example above:
}\. looks for a single DOT
}. looks for ANY character (except newline).
Your previous posting says:
To find lines with a hyphen in position 77, you need: ^.{76}-
To find lines with a dot in position 77, you need: ^.{76}\.
So, I was correct in saying that "the character I want to find follows the last brace (instead of the ^)".
In your second example above:
}\. looks for a single DOT
}. looks for ANY character (except newline).