onComplete[U](f: (Try[T]) ⇒ U)(implicit executor: ExecutionContext): Unit
onSuccess[U](pf: PartialFunction[T, U])(implicit executor: ExecutionContext): Unit
onFailure[U](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Unit
想要将其转换为:
6/9/1985 1234567890 XYZ ABC test@yahoo.co.in 301 DURGA NIWAS
所以,我想要的是,如果在数字(例如6/9/1985 1234567890 xyz_abc_test@yahoo.co.in 301 DURGA NIWAS
)和电子邮件(例如1234567890
)之间存在任何字母数字字符,那么我需要用小写字符替换,而空格将替换为下划线。
答案 0 :(得分:0)
您可以将replace
与回调一起使用:
var t = '6/9/1985 1234567890 XYZ ABC test@yahoo.co.in 301 DURGA NIWAS';
var r = t.replace (
/((?:^|\s)\d+\s+)((?:[a-z]\w*\b\s+)*)(?=[^\s@]+@)/gim,
function($0, $1, $2) {
return $1 + $2.toLowerCase().replace(/\s/g, "_");
}
);
//=> "6/9/1985 1234567890 xyz_abc_test@yahoo.co.in 301 DURGA NIWAS"