我只想替换shell中的确切字符串。
import UIKit
class ViewController: UIViewController {
var other: ViewControllerB!
override func viewDidLoad() {
super.viewDidLoad()
other = ViewControllerB(other: self)
}
}
class ViewControllerB: UIViewController {
let other: UIViewController
init(other: UIViewController) {
self.other = other
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
输出必须是:
str="My name is Sourav. My user name is Souravc. Sourav and Souravc is great person"
to_be_rplace="Sourav"
rplace_with=67776
答案 0 :(得分:0)
使用\< pattern \>
$ sed 's/\<Sourav\>/67776/g' file
$ echo "My name is Sourav. My user name is Souravc. Sourav and Souravc is great person" | sed 's/\<Sourav\>/67776/g'
My name is 67776. My user name is Souravc. 67776 and Souravc is great person