複数のキャプチャ グループで一致させるために文字列を検索しようとしています。このような 2 つのキャプチャ グループの場合、データはオプションであるため、一致する場合と一致しない場合があります。オプション -onumber を指定して pcregrep を使用して、さまざまなキャプチャ グループを返します。問題は、値が一致しない場合にデフォルト値を返すにはどうすればよいかです。選言を使用しようとしましたが、成功しませんでした。
例:
../pcre-8.32/pcregrep -Min -o1 -o2 --om-separator="; " '(?s)<!-- BOUNDARY -->(?!.*?Read the full review).*?((\d*) of (\d*) people found the following review helpful|.*?).*?Help other customers find the most helpful' shirts/B000W18VGW
正しい行番号を生成します。
-Min -o1 -o2 --om-separator="; " '(?s)<!-- BOUNDARY -->(?!.*?Read the full review).*?(\d*) of (\d*) people found the following review helpful.*?Help other customers find the most helpful' shirts/B000W18VGW
正しい出力を生成しますが、次の行に対してのみです
(\d*) of (\d*) people found the following review helpful
上記の行が存在しない場合は、キャプチャ グループごとに「0」を返したいと思います。
これは可能ですか?