strReplance remove linebreaks

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

strReplance remove linebreaks

12 Jul 2018, 20:02

I have a text file with one word a line. How to change the selected text so that I end up with one line with the words separated by a comma and a space. I've tried doing a strReplace using "`n" but although I can add commas and spaces I can't remove the actual linebreaks so I still end up with one word a line. How to remove the linebreaks, thanks.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: strReplance remove linebreaks

12 Jul 2018, 20:19

Hi.
As StrReplace(...) turns back a value, you have to assign this to a variable as shown below:

Code: Select all

myText := strReplace(myText, "`n", "`,")
Maybe you have to delete all `r if they are present. Then you can combine like below:

Code: Select all

myText := strReplace(strReplace(myText, "`n", "`,"), "`r")
Einfach nur ein toller Typ. :mrgreen:
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: strReplance remove linebreaks

12 Jul 2018, 23:17

- Try this perhaps:

Code: Select all

vText := "a`r`nb`r`nc"
MsgBox, % vText
vText := StrReplace(vText, "`r`n", ", ")
MsgBox, % vText
- To investigate the text you can try this:

Code: Select all

vText := "a`r`nb`r`nc"
vText := StrReplace(vText, "`r", "_R")
vText := StrReplace(vText, "`n", "N_")
MsgBox, % vText
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: strReplance remove linebreaks

14 Jul 2018, 16:39

Thanks for the replies, jeewg had the solution. Putting `r and `n together did the trick.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 305 guests