在 Automator 中使用 AppleScript 替换字符
Using AppleScript in Automator for replacing characters
我想在 Apple Automator 中创建服务以将字符替换为其他字符。例如,如果我想转换 phone 数字格式:
+X(XXX)XXX-XX-XX => XXXXXXXXXX
谢谢。
这是一个简单的 applescript 代码,您可以将其放入自动程序中,它 returns 输出为一个完整的数字 = XXXXXXXXXX
on run {input, parameters}
set inputNumber to input as text
set outputNumber to ""
if inputNumber begins with "+" then
-- The Number begins with a + so convert number
set noParts to the number of words of inputNumber
repeat with cPart from 3 to noParts
set outputNumber to outputNumber & word cPart of inputNumber
end repeat
end if
return outputNumber
end run
希望对您有所帮助!
我想在 Apple Automator 中创建服务以将字符替换为其他字符。例如,如果我想转换 phone 数字格式:
+X(XXX)XXX-XX-XX => XXXXXXXXXX
谢谢。
这是一个简单的 applescript 代码,您可以将其放入自动程序中,它 returns 输出为一个完整的数字 = XXXXXXXXXX
on run {input, parameters}
set inputNumber to input as text
set outputNumber to ""
if inputNumber begins with "+" then
-- The Number begins with a + so convert number
set noParts to the number of words of inputNumber
repeat with cPart from 3 to noParts
set outputNumber to outputNumber & word cPart of inputNumber
end repeat
end if
return outputNumber
end run
希望对您有所帮助!