我有这个 AppleScript 片段,可以很好地用 ' 替换 ` :
set strng to "Output`s new form should not be these'\\''chars"
set modifiedString to replaceChars(strng, "`", "'")
on replaceChars(inputText, charsOut, charsIn)
set text item delimiters to charsOut
set textList to text items of inputText
set modifiedList to {}
repeat with textItem in textList
set end of modifiedList to textItem as text
end repeat
set text item delimiters to charsIn
set resultText to modifiedList as text
set text item delimiters to ""
return resultText
end replaceChars
我想扩展它,以便它也搜索 '\'' 序列并替换为 ' 。 有点像:
set modifiedString to replaceChars(strng, {"`", "'\\''"}, "'")
如何过滤这个附加字符串?
注意,我也愿意通过 shell 命令执行此操作,但到目前为止,只有这种方法对我使用“`”字符有效。
set modifiedString to replaceChars(strng, {"`", "'\\''"}, "'")
...毕竟对我有用。 感谢您的投入