如何在Perl中获取连续的单词对

前端之家收集整理的这篇文章主要介绍了如何在Perl中获取连续的单词对前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
用这句话:

my $sent = "Mapping and quantifying mammalian transcriptomes RNA-Seq";

我们想要获得所有可能的连续单词对.

my $var = ['Mapping and','and quantifying','quantifying mammalian','mammalian transcriptomes','transcriptomes RNA-Seq'];

有一种紧凑的方式吗?

解决方法

是.

my $sent = "Mapping and quantifying mammalian transcriptomes RNA-Seq";
my @pairs = $sent =~ /(?=(\S+\s+\S+))\S+/g;

猜你在找的Perl相关文章