Regular expression quandry

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Jaybird
Posts: 2
Joined: Fri Aug 01, 2003 9:06 pm

Regular expression quandry

Post by Jaybird »

Wondering if anyone could help here. I really have gone through the help and search online but I am stumped. I need to accomplish either of the following in the sample below:

a) Find and remove everyting but the contents in bold
or;
b) Find and remove the entire lines highlighted in blue

Note that wildcards of some type are required because the time is changing in each line. Everything I try either only selects part of the line, says not found, or invalid regular expression. Now I have tried the sneaky "bookmark the lines I don't want deleted and invert" but I'd like to try to learn how to do it using reg expressions.

SAMPLE:
[Thu Jul 31 08:32:48 2003]Local/GLDetail/GLDetail/jplater/Info(1020019)
The sheet contains an unknown member: lp_Qtr_LPW10641_Data.

[Thu Jul 31 08:32:49 2003]Local/GLDetail/GLDetail/jplater/Info(1020019)
The sheet contains an unknown member: lp_YTD_LPW10641_Data.

[Thu Jul 31 08:33:01 2003]Local/GLDetail/GLDetail/jplater/Info(1020019)
The sheet contains an unknown member: lp_Qtr_LPW10080_Data.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Hi Jaybird, Looks like data is on two lines. Try this to remove all in BLUE.................

1. Move cursor to top of document

2. Open Search, Replace, Select: Text, Regular expression, Active Document

Search for: ^\[.*)

Replace with: (Leave blank)

Click on Replace All................DONE!

3. Click on Close to close Replace window.
==================
Explanation of RegEx:

^ is beginning of line
\[ is look for "["
. is any character/space/number
* is any quantity of preceeding character (.)
) is look for ")"

OR
Look for any group of characters from the beginning of the line that starts with "[" and ends with a ")".
==================
If all data (BLUE and black and BOLD) is on the same line then, use this to remove all but the BOLD:

Search for: ^\[.*:[: :]
Replace with: (leave blank)
==================
Explanation of RegEx:

^ is beginning of line
\[ is look for "["
. is any character/space/number
* is any quantity of preceeding character (.)
: is look for ":"
[: :] is a space character

OR
Look for any group of characters from the beginning of the line that starts with "[" and ends with a colon followed by a space.
==================


Have a backup available or be prepared to use Edit, Undo if problems.

Hope this helps.................good luck,
Bob
Jaybird
Posts: 2
Joined: Fri Aug 01, 2003 9:06 pm

Thanks!

Post by Jaybird »

Thanks Bob. The nuance that I have been missing all along with the regular expressions involved putting the . before the * when doing wildcard searches

Thank you for helping me see the light
Post Reply