次のような行がいくつかあります。
function( "((2 * VAR(\"xxx\")) - VAR(\"yyy\"))" ?name "name" ?plot t ?save t ?evalType 'point)
function("value(res VAR(\"zzz\"))" ?name "othername" ?plot t ?save t ?evalType 'point)
そして、VAR関数で定義された文字列を出力するコマンドを見つけたいと思います。
xxx yyy
zzz
私は試してみましたsed
が、私が理解しているように、貪欲でない方法でそれを行う方法はありません。
grep
Perl互換正規表現(PCRE)をサポートするがあれば、次を使用できます。
grep -Po 'VAR\(\\"\K[^\\]*'
または(より対称的に-ルックビハインドとルックアヘッドを使用)
grep -Po '(?<=VAR\(\\").*?(?=\\")'
例
$ grep -Po 'VAR\(\\"\K[^\\]*'
function( "((2 * VAR(\"xxx\")) - VAR(\"yyy\"))" ?name "name" ?plot t ?save t ?evalType 'point)
function("value(res VAR(\"zzz\"))" ?name "othername" ?plot t ?save t ?evalType 'point)
xxx
yyy
zzz
例
$ grep -Po '(?<=VAR\(\\").*?(?=\\")'
function( "((2 * VAR(\"xxx\")) - VAR(\"yyy\"))" ?name "name" ?plot t ?save t ?evalType 'point)
function("value(res VAR(\"zzz\"))" ?name "othername" ?plot t ?save t ?evalType 'point)
xxx
yyy
zzz
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加