 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
degarb
Joined: 14 Feb 2007 Posts: 307
|
Posted: Thu Jan 28, 2010 10:44 pm Post subject: stripping out double `n |
|
|
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 |
|
 |
randallf
Joined: 06 Jul 2009 Posts: 678
|
Posted: Thu Jan 28, 2010 10:46 pm Post subject: |
|
|
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 |
|
 |
poo_noo
Joined: 08 Dec 2006 Posts: 248 Location: Sydney Australia
|
Posted: Thu Jan 28, 2010 11:45 pm Post subject: |
|
|
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 |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Thu Jan 28, 2010 11:48 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|