我的数据是:
- List item
- COL_DPU_JA08 Cash Remit 3/09/2017 ILA WSE
- COL_DPU_MBTC_CJPM_03.09.17
- COL_DPU_CJOA_CA_3.9.17
- COL_DPU_CJNA_CA_03/09/2017
- COL_POS_CJDB_BDO_03092017
- COL_DPU_JE12 Cash Remit 3/09/2017 TUG WSE
- COL_DPU_JA08 Checks Remit 3/10/17 ILA
如何提取日期并将所述日期转换为以下格式: 的 MM.DD.YY
答案 0 :(得分:2)
由于您没有提供您正在使用的语言,因此这是一个执行此任务的perl脚本:
#!/usr/bin/perl
use Modern::Perl;
use Data::Dump qw(dump);
my $re = qr~[ _](\d\d?)\D?(\d\d?)\D?(?:\d\d)?(\d\d)\b~;
while(<DATA>) {
chomp;
my (@l) = $_ =~ $re;
dump@l;
}
__DATA__
- COL_DPU_JA08 Cash Remit 3/09/2017 ILA WSE
- COL_DPU_MBTC_CJPM_03.09.17
- COL_DPU_CJOA_CA_3.9.17
- COL_DPU_CJNA_CA_03/09/2017
- COL_POS_CJDB_BDO_03092017
- COL_DPU_JE12 Cash Remit 3/09/2017 TUG WSE
- COL_DPU_JA08 Checks Remit 3/10/17 ILA
<强>输出:强>
(3, "09", 2017)
("03", "09", 17)
(3, 9, 17)
("03", "09", 17)
("03", "09", 17)
(3, "09", 17)
(3, 10, 17)