I did spend about an hour + on searching and trying to understand regular expressions .... but I'm still feel stupid......
Have the following line (or similar) in many files:
421 CL3000 NREQD 5 - - - - - - SCAQZZZAAA - CAPOT 5375 -
421 CL3000 NREQD 5 - - - - - - SCAQZZZAAA - CAPOT 5375 -
421 CL3000 NREQD 5 - - - - - - SCAQZZZAAA - CAPOT 5375 -
421 CL3000 NREQD 5 - - - - - - SCAQZZZAAA - CAPOT 5375 -
441 CL3000 NREQD 5 - - - - - - TCAQZZZAAA - CAPOT 41 -
421 CL6000 NREQD 5 - - - - - - SCARZZZAAA - CAPOT 5375 -
421 CL9000 NREQD 5 - - - - - - SCASZZZAAA - CAPOT 4725 -
I would like to find all the lines with CL3000 and CAPOT
Go ahead show me how simple
PS: sorry for being so dumb
THX in advance !!!
Simple Search "Find in Files"
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Do you mean you want to find all lines containing CL3000 and CAPOT in that order?
This regular expression will find text that begins with CL3000 and ends with CAPOT on a single line:
CL3000.*CAPOT
How you use this expression depends on exactly what you want to do with the lines when you've found them.
If you just want to bookmark the lines, perhaps to copy them elsewhere, do this:
This regular expression will find text that begins with CL3000 and ends with CAPOT on a single line:
CL3000.*CAPOT
How you use this expression depends on exactly what you want to do with the lines when you've found them.
If you just want to bookmark the lines, perhaps to copy them elsewhere, do this:
Find what: CL3000.*CAPOT
[X] Regular expression
Mark All
THX so MUCH ben
I'm still a little confused, not sure I understand why the . makes such a difference, I tried CL3000*CAPOT, but as you know that does not work.
Again THX for the help and getting me started, will gradually graduate higher as time goes by.
PS: currently just search not needing to edit, just looking for data I need to input into another form/app
Regular Expressions (POSIX)
====================
. Any single character.
[ ] Any one of the characters in the brackets, or any of a
range of characters separated by a hyphen (-), or a
character class operator (see below).
[^] Any characters except for those after the caret "^".
^ The start of a line (column 1).
$ The end of a line (not the line break characters).
\< The start of a word.
\> The end of a word.
\t The tab character.
\f The page break (form feed) character.
\n A new line character, for matching expressions that span
line boundaries. This cannot be followed by operators
'*', '+' or {}. Do not use this for constraining matches to
the end of a line. It's much more efficient to use "$".
\xdd "dd" is the two-digit hexadecimal code for any
character.
\( \) Groups a tagged expression to use in replacement
expressions. An RE can have up to 9 such expressions.
\| Matches either the expression to its left or its right.
* Matches zero or more preceding characters/expressions.
? Matches zero or one preceding characters/expressions.
+ Matches one or more preceding characters/ expressions.
{count} Matches the specified number of the preceding
characters or expressions.
{min,} Matches at least the specified number of the preceding
characters or expressions.
{min,max} Matches between min and max of the preceding
characters or expressions.
I'm still a little confused, not sure I understand why the . makes such a difference, I tried CL3000*CAPOT, but as you know that does not work.
Again THX for the help and getting me started, will gradually graduate higher as time goes by.
PS: currently just search not needing to edit, just looking for data I need to input into another form/app
Regular Expressions (POSIX)
====================
. Any single character.
[ ] Any one of the characters in the brackets, or any of a
range of characters separated by a hyphen (-), or a
character class operator (see below).
[^] Any characters except for those after the caret "^".
^ The start of a line (column 1).
$ The end of a line (not the line break characters).
\< The start of a word.
\> The end of a word.
\t The tab character.
\f The page break (form feed) character.
\n A new line character, for matching expressions that span
line boundaries. This cannot be followed by operators
'*', '+' or {}. Do not use this for constraining matches to
the end of a line. It's much more efficient to use "$".
\xdd "dd" is the two-digit hexadecimal code for any
character.
\( \) Groups a tagged expression to use in replacement
expressions. An RE can have up to 9 such expressions.
\| Matches either the expression to its left or its right.
* Matches zero or more preceding characters/expressions.
? Matches zero or one preceding characters/expressions.
+ Matches one or more preceding characters/ expressions.
{count} Matches the specified number of the preceding
characters or expressions.
{min,} Matches at least the specified number of the preceding
characters or expressions.
{min,max} Matches between min and max of the preceding
characters or expressions.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
AlienX69 wrote:I'm still a little confused, not sure I understand why the . makes such a difference
So .* matches zero or more single characters, that is, any string of characters.AlienX69 also wrote:Regular Expressions (POSIX)
====================
. Any single character.
...
* Matches zero or more preceding characters/expressions.
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.
A standard reference for regular expressions is
Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/
But be aware that the regular expression recogniser used by TextPad is well beyond its retirement age and is considerably weaker than younger tools. So you may get frustrated if you discover a handy trick that works elsewhere but doesn't work in TextPad.
Find in files
the same thing but got to search files containing two strings ? (but not neccerarily in the same line).
Exlcellant feature
use it alot.