我需要模仿以下Perl代码的功能
if($file =~ /^([^_]+)_([^_]+)_MA_(\d{4})(\d\d)(\d\d)_(\d\d)(\d\d)(\d\d)\.MA$/) {
my ($radar, $beam, $year, $month, $day, $hour, $min, $sec) =
($1, $2, $3, $4, $5, $6, $7, $8);
my $file_ts = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
$year, $month, $day, $hour, $min, $sec);
# ...
}
Run Code Online (Sandbox Code Playgroud)
在C++中.我使用哪种功能?
好吧,总有选择使用sprintf:
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
或者你可以使用stringstream,作为更多的C++ - 替代品.