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.
我将以下行分配给一个变量:
"[ some contents ] NAME:saranyya"
我怎样才能grep得到这个模式之后的一个词?
grep
一个简单的捕获可能会满足您的需要。虽然目前还不清楚你的意思。
my ($word) = $string =~ /\Q[ some contents ] NAME:saranyya \E(.+)/;
转义将允许在您的正则表达式\Q .. \E中使用元字符。[]遵循您的模式的任何文本都将被捕获并分配给$word.
\Q .. \E
[]
$word