我有一个看起来像这样的记录集
"BOSW0001","Mr","Wayne","Boswell","Wayne,Jessica & Lyn","31 Baker St"
"ELLI0007","Mrs","Bronwyn","Elliott","Bronwyn, Paul & Arianne","98A Dandaraga Rd"
"KENN0001","Mr","Leigh","Kenning","Leigh & Beth,Cole","22 Lake St"
Run Code Online (Sandbox Code Playgroud)
我想,用pipe(|)替换逗号()而不替换里面的逗号
"Leigh & Bethie,Coles"
"Waynez,Jessy & Lyne"
"Bronwynie, Paula & Arianne"
Run Code Online (Sandbox Code Playgroud)
如何使用正则表达式或其他方法执行此操作?
例如,我的时间范围如下:
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Run Code Online (Sandbox Code Playgroud)
而我想要的只是使用grep -E'[1-2] [??]来获取13到20之间的数字是否可能?
请不要给出关于awk的答案我不是在问它非常感谢你
如何创建一个接受所有类型变量的子例程并确定它是否是(标量,散列,数组或引用)
sub know_var {
my $this_var = shift;
if ($this_var eq "array"){
print "This variable is an array!";
} elsif ($this_var eq "hash") {
print "This variable is a hash!";
} elsif ($this_var eq "hash ref") {
print "This variable is an hash reference!";
} so on..
}
my @array = ('foor', 'bar');
my %hash = (1 => "one", 2 => "two");
my $scalar = 1;
my $scalar_ref = \$scalar;
my $hash_ref = \%hash;
my $arr_ref = \@array;
know_var(@array);
know_var($scalar_ref); …Run Code Online (Sandbox Code Playgroud)