AutoHotkey Community

It is currently May 27th, 2012, 5:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: March 16th, 2010, 7:50 pm 
Offline

Joined: March 6th, 2010, 9:26 am
Posts: 15
Location: India
I need AHK script to remove line breaks from blocks of text but preserve paragraph breaks.

same like this tool

http://www.textfixer.com/tools/remove-line-breaks.php


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2010, 8:06 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Something like this?
Code:
NewString := RegExReplace(OldString,"\s+"," ")

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 3:17 pm 
Offline

Joined: October 9th, 2009, 8:36 pm
Posts: 93
you can do it with a StringReplace however i don't know what the value is for line breaks

Quote:
; Replace all spaces with pluses:
StringReplace, NewStr, OldStr, %A_SPACE%, +, All


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 3:25 pm 
Offline

Joined: October 9th, 2009, 8:36 pm
Posts: 93
k it should be something like

Quote:
StringReplace, NewStr, OldStr, `r`n, , All


try that


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 3:53 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
Not the most elegant solution, but try the below. It seems to have the same results as that tool you linked for me.

Code:
String =
(
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam elementum ipsu
murna. Maecenas adipiscing, odio at commodo sollicitudin, turpis nisl pellent
esque nisl, a semper erat tellus sed tortor. Vivamus turpis dui, varius in eg
estas sit amet, vulputate a augue. Nam vulputate diam vel nisl faucibus laore
et aliquam leo aliquet.

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac
turpis egestas. Pellentesque habitant morbi tristique senectus et netus et ma
lesuada fames ac turpis egestas. Sed sed augue lectus. In condimentum convall
is elit, ut tempus quam ullamcorper id.

Proin eget varius nibh. Nunc tincidunt convallis pharetra. Nunc viverra tellu
s in libero consectetur pharetra tempus felis posuere. Donec consequat pellen
tesque laoreet. Proin rhoncus magna rhoncus nibh tristique fermentum.
)

MsgBox, BEFORE`n`n%String%

StringReplace, String, String, `n`n,||,All
StringReplace, String, String, `n,, All
StringReplace, String, String, ||,`n`n,All

MsgBox, AFTER`n`n%String%


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], Google Feedfetcher, mrhobbeys, rbrtryn and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group