如何在AppleScript中替换“\ n”?

时间:2012-09-22 17:49:43

标签: macos applescript

我想在Applescript中替换“\ n”。每当我写下它时,它只会将\n之后的内容带到下一行。我该怎么做?

set newVar to my replaceText("\n/blah-blah", "")

编辑:

set newVar to my replaceText(linefeed, "", newVar)
log newVar

newVar仍会以\n打印到最后。

3 个答案:

答案 0 :(得分:9)

找到问题的解决方案,转到首选项 - >编辑并检查字符串中的转义标签和换行符

http://forums.macrumors.com/showthread.php?t=1395073

答案 1 :(得分:8)

这应该抓住他们所有人:

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

使用“blah \ n”作为oldText enter image description here

答案 2 :(得分:2)

使用linefeed AppleScript constant

set newVar to my replaceText(linefeed & "/blah-blah", "")