Page 1 of 1
find the first sentence and remove the rest
Posted: Fri Apr 05, 2013 3:13 pm
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
Posted: Fri Apr 05, 2013 4:21 pm
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
Posted: Fri Apr 05, 2013 4:43 pm
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
Posted: Fri Apr 05, 2013 7:17 pm
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".
Posted: Fri Apr 05, 2013 7:25 pm
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.
Posted: Fri Apr 05, 2013 7:33 pm
by bbadmin
In that case, try searching for:
^(.{X}).+
(where X is the width of the column)
and replacing it with:
$1
Posted: Sun Apr 07, 2013 1:31 pm
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!