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.
了解しました。これはおそらく答えるのが非常に簡単な質問ですが、私はそれに苦労しています。特定の単語の後のすべてをキャプチャして印刷するようにプログラムを取得しようとしています。たとえば、入力テキストが
bar foo foo foo foo
次に、バーを検索する場合は、出力を「foofoofoofoo」にします。私の質問が理にかなっていることを願っています。どんな助けでも大歓迎です!私はperlに非常に慣れていないので、説明が多ければ多いほどよいでしょう。ありがとうございました!
#! /usr/bin/env perl *ARGV = *DATA; # for demo only while (<>) { print "line $.: $1\n" if /bar\s+(.+)/; } __DATA__ you can't see me bar foo foo foo foo nope
出力:
2行目:foo foo foo foo