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.
假设我有一个数组
@arr = qw( 12 2 5 bba<1s54> 10 11 )
在这种情况下,如何从该数组中删除非数字项"bba<1s54>"?
"bba<1s54>"
这个独特的“术语”有格式"bba<...>"。是否可以使用正则表达式删除它?
"bba<...>"
您只能grep得到数字的结果:
grep
my @arr = qw(12 2 5 bba<1s54> 10 11); @arr = grep /^\pN+$/, @arr;
如果您确切知道要删除的内容,则删除它会更加严格。例如:
@arr = grep !/bba<.*>/, @arr;