Trying to replace | with `n using StringReplace Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Barnaby Ray
Posts: 45
Joined: 09 Nov 2021, 07:48

Trying to replace | with `n using StringReplace

Post by Barnaby Ray » 24 May 2022, 09:38

Hi, please can anyone help me understand StringReplace?

I have a text file where i want to change the | symbol into `n for line breaks.
So in the text file I have

Track 01 (GX4R52297054)|Track 02 (GX4R52297056)|Track 05 (GX4R52297065)|

and want it to be

Track 01 (GX4R52297054)
Track 02 (GX4R52297056)
Track 05 (GX4R52297065)

I've tried all sort of combinations with string replace, but keep getting error messages saying | is an illegal character.

Something like this, although this doesn't work:

Code: Select all

^+t::
	FileRead, LineBreak, out.txt
	LineBreak2 := StringReplace(LineBreak, "|", "`n")

    MsgBox, % LineBreak2
     return
Thank you!

RussF
Posts: 1260
Joined: 05 Aug 2021, 06:36

Re: Trying to replace | with `n using StringReplace

Post by RussF » 24 May 2022, 09:42

The function is StrReplace(). StringReplace is a command and is deprecated.

Russ

Barnaby Ray
Posts: 45
Joined: 09 Nov 2021, 07:48

Re: Trying to replace | with `n using StringReplace  Topic is solved

Post by Barnaby Ray » 24 May 2022, 09:55

Ah thank you! Got it working now :)

Code: Select all

^+t::
	FileRead, LineBreak, out.txt
	LineBreak2 := StrReplace(LineBreak, "|", "`n")
    MsgBox, % LineBreak2
	return

Post Reply

Return to “Ask for Help (v1)”