AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

stripping out double `n

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
degarb



Joined: 14 Feb 2007
Posts: 307

PostPosted: Thu Jan 28, 2010 10:44 pm    Post subject: stripping out double `n Reply with quote

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%
Back to top
View user's profile Send private message
randallf



Joined: 06 Jul 2009
Posts: 678

PostPosted: Thu Jan 28, 2010 10:46 pm    Post subject: Reply with quote

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
}
Back to top
View user's profile Send private message
poo_noo



Joined: 08 Dec 2006
Posts: 248
Location: Sydney Australia

PostPosted: Thu Jan 28, 2010 11:45 pm    Post subject: Reply with quote

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/StringReplace.htm
_________________
Paul O
Back to top
View user's profile Send private message Visit poster's website
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Thu Jan 28, 2010 11:48 pm    Post subject: Reply with quote

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.
"

Antonio França
My stuff: Google Profile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group