以下是 man expr 的部份內容:
STRING : REGEXP附上相關例子:
Pattern matches return the string matched between \( and \) or null; if \( and \) are not used, they return the number of characters matched or 0.
$ expr "hello world" : "hello.*"有了 expr, 以後湊指令方便多啦
11
$ expr "hello world" : "hello"
5
$ expr "hello world" : "hello \(.*\)"
world
沒有留言:
張貼留言