AutoHotkey Community

It is currently May 27th, 2012, 1:58 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: stripping out double `n
PostPosted: January 28th, 2010, 11:44 pm 
Offline

Joined: February 14th, 2007, 8:01 pm
Posts: 308
I am trying to strip out double line breaks with no luck. What am I doing wrong?

fileread, chopthis,%a_workingdir%\DownloadedCasts\%plist%
stringreplace,chopthis,chopthis,%RowText%,
stringreplace,chopthis,chopthis,`n`n`n,`n,1
stringreplace,chopthis,chopthis,`n`n,`n,1
fileappend,%chopthis%,%a_workingdir%\DownloadedCasts\%plist%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2010, 11:46 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Untested:
Code:
While Var contains `n
{
   StringReplace, Var, Var, `n
}


If not that maybe
Code:
n_ := "`n"
While Var contains %n_%
{
   StringReplace, Var, Var, `n
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2010, 12:45 am 
Offline

Joined: December 8th, 2006, 5:17 am
Posts: 248
Location: Sydney Australia
Does this work ?

Code:
fileread, chopthis,%a_workingdir%\DownloadedCasts\%plist%
stringreplace,chopthis,chopthis,%RowText%,
; Remove all blank lines from the text in a variable:
Loop
{
    StringReplace, chopthis, chopthis, `r`n`r`n, `r`n, UseErrorLevel
    if ErrorLevel = 0  ; No more replacements needed.
        break
}


fileappend,%chopthis%,%a_workingdir%\DownloadedCasts\%plist%


Have a look at examples in the help for stringreplace

http://www.autohotkey.com/docs/commands ... eplace.htm

_________________
Paul O


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2010, 12:48 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
RegEx solution:
Code:
NewString := RegExReplace(OldString,"\R+", "`r`n")

Not sure if you want that `r there.

_________________
"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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, engunneer, JSLover, rbrtryn, sjc1000 and 21 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