How to replace "\n" in AppleScript?

applescript, macos

Solution

This should catch them all:

set oldText to "line 1
line 2
line 3"

set AppleScript's text item delimiters to {return & linefeed, return, linefeed, character id 8233, character id 8232}
set newText to text items of oldText
set AppleScript's text item delimiters to {" "}
set newText to newText as text

using "blah\n" as oldText

Problem

I want to replace "\n" in Applescript. Whenever I write that, it just brings whatever is after `\n` to the next line. How do I do that? ``` set newVar to my replaceText("\n/blah-blah", "") ``` EDIT: ``` set newVar to my replaceText(linefeed, "", newVar) log newVar ``` `newVar` still prints with `\n` towards the end.

Original source