Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
正規表現で一致したグループを除くすべてを削除する必要があります。おもちゃの例は次のようになります。
echo 'spam 123 ham 345 eggs' | perl -pe 's/( \d+ )/SOMETHING/g' 123 345
どのperl正規表現が一致したグループ以外のすべてを削除しますか?一致するグループは、単なる数字よりも複雑になる可能性があります-一致するグループを定義できますが、グループの外部には任意のランダムな文字を含めることができます
代わりにすべての試合に参加してください。私はPerlを知りませんが、このようなものが機能するかもしれません:
$result = join('', $subject =~ m/\s*\d+\s*/g);