如何在AppleScript中使用sed在html文件中查找/替换所有实例?

时间:2018-10-24 23:17:58

标签: macos sed applescript

我的目标是替换(代替)

的任何实例
componentWillReceiveProps(nextProps) {

    // If the incoming file prop doesn't match the current file
    // prop of this component instance, update internal state via
    // setState to trigger a re-render, and call methodToCheckFileType()
    // as in your componentDidMount() method
    if(nextProps.file !== this.props.file) {

    this.setState({ file : nextProps.file })         

    this.methodToCheckFileType(nextProps.file)
    .then(response => {
        this.setState({
            url: response.url
        });
    })
    }
 }

使用

src="[random text i want to remove]http

在html文件中。要点:我需要使用AppleScript来做到这一点。代码如下:

src="http

出现错误:

set myfile to "pathto/test.html"

do shell script "sed -i 's/src=\"*.+http/src=\"http/g' " & quoted form of myfile

我不确定这个错误是什么意思……希望有人可以帮助您!

1 个答案:

答案 0 :(得分:0)

这有效:

Foo.Bar('/"foo/"').bar("foo(bar/")")

-i后面必须有一个空格。

相关问题