find the first sentence and remove the rest

General questions about using TextPad

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

Post Reply
hoachen
Posts: 9
Joined: Mon Nov 24, 2003 1:21 pm

find the first sentence and remove the rest

Post by hoachen »

I have a text file that contrains the data that I need, but I only the first sentense that i will need. I know i can do it using excel but, when the data like 56E6 excel will change it to exponent that is why I need to use reg expression.

Data look like:
12Akd something I dont want Other than first string
dfl6AB something I dont want Other than first string
U9AO something I dont want Other than first string

The output I am looking for is
12Akd
dfl6AB
U9AO

Thanks
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do you mean you only want the first word of each line? And are the words separated by spaces? If so, try this:
Find what: _.* [Replace the underscore with a space]
Replace with: [nothing]

[X] Regular expression

Replace All
hoachen
Posts: 9
Joined: Mon Nov 24, 2003 1:21 pm

Post by hoachen »

Column1 Column2 Column3 Column4
12Akd something I dont want Other than first string
dfl6AB something I dont want Other than first string
U9AO something I dont want Other than first string


I only want column1
User avatar
bbadmin
Site Admin
Posts: 879
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

Assuming the columns are separated by a unique character, use the method ben josephs described, replacing the "_" with the unique character. If the separator is a tab, use "\t".
hoachen
Posts: 9
Joined: Mon Nov 24, 2003 1:21 pm

Post by hoachen »

the first column and second column are seperate by a fix spacing. I know I can use \t to seperate them, but I only one the first column only. I need the reg expr to remove all after the first column ending with space.
User avatar
bbadmin
Site Admin
Posts: 879
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

In that case, try searching for:

^(.{X}).+

(where X is the width of the column)

and replacing it with:

$1
hoachen
Posts: 9
Joined: Mon Nov 24, 2003 1:21 pm

Post by hoachen »

bbadmin wrote:In that case, try searching for:

^(.{X}).+

(where X is the width of the column)

and replacing it with:

$1

*****************************************
This is will work!! Thank you so much!
Post Reply