add enter in txt files

General discussions about Advanced Find and Replace
Post Reply
kasjan
Posts: 4
Joined: Sun Oct 15, 2006 6:48 pm

add enter in txt files

Post by kasjan »

Hello how i can do something like that:

I have this in txt file:
02h00GMT 5146.49 05h00GMT 5146.49 07h00GMT 5182.04 07h10GMT 5183.14 07h20GMT 5179.29 07h30GMT 5182.89 07h40GMT 5189.93 07h50GMT 5190.87 08h00GMT 5194.33 08h10GMT 5198.78 08h20GMT 5202.05 08h30GMT 5196.33 08h40GMT 5200.43 08h50GMT 5196.92 09h00GMT 5199.25 09h10GMT 5197.99 09h20GMT 5201.05 09h30GMT 5198.18

I wanna this:
02h00GMT 5146.49
05h00GMT 5146.49
07h00GMT 5182.04
07h10GMT 5183.14
and so on

Can you help me write code?
Thanks

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

How many 02h00GMT 5146.49 pairs do you have in one line?
It's it fixed number?
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

kasjan
Posts: 4
Joined: Sun Oct 15, 2006 6:48 pm

Post by kasjan »

fixed number unfortunatelly or one :( in one line will be all i dont see this because word curl up (wrap) sorry to my english

can i write thir regular 3 places on left after "h" add enter ?and will be OK

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Go to Batch replace tab, check on "Use regular expressions".
In fact "enter" in terms of regular expressions is:
\r\n

Now in order identify one pair we can use the following:
\d+h\d+GMT \d+\.\d{2}

First of all you may try the following:
Put into the grid, search for:
(\d+h\d+GMT \d+\.\d{2})
Replace with:
$1\r\n

Now if you need more precise results:
for example you have 5 pairs in one line and each line ends with enter
(\r\n\)

in this case use the following:
Search for:
(\d+h\d+GMT \d+\.\d{2}) (\d+h\d+GMT \d+\.\d{2}) (\d+h\d+GMT \d+\.\d{2}) (\d+h\d+GMT \d+\.\d{2}) (\d+h\d+GMT \d+\.\d{2})\r\n
Replace with:
$1\r\n
$2\r\n
$3\r\n
$4\r\n
$5
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

kasjan
Posts: 4
Joined: Sun Oct 15, 2006 6:48 pm

Post by kasjan »

yea this works :) but i found in my txt files value like this:

10h10GMT 5200.8 10h20GMT 5205.0 10h30GMT 5203.86 10h40GMT 5203.05 10h50GMT 5208.17 11h00GMT 5208.62 11h10GMT 5210.68 11h20GMT 5210.34 11h30GMT 5208.08 11h40GMT 5206.3 11h50GMT 5203.1 12h00GMT 5200.3 12h10GMT 5205.8 12h20GMT 5205.31

if you see after dot will be sometimes one decimal :( "d{2}" must be change but for what :/

I dont have another data only these problem it is one digit but sometimes is 2 digit after dot

Can you resolve this problem?
i no have idea how to do that

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Go to main menu - Action - Options - Batch Replace
check "Modifier G"
so we should enable greedy mode.

Then in above examples use \d+ instead of \d{2}

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

kasjan
Posts: 4
Joined: Sun Oct 15, 2006 6:48 pm

Post by kasjan »

its work!!!!! :lol: :lol: :lol: :lol:

Thank you!

Post Reply