class Solution {
public static void main
(String[] args
) { String s
= "00-44 48 5555 8361"; System.
out.
println(solution
(s
)); String s2
= "00-44 48 5555 8361 xxx 1"; System.
out.
println(solution
(s2
)); System.
out.
println(solution
(s3
)); }
return s.replaceAll("[^\\d]", "").replaceAll("...", "$0-").replaceAll("-$", "");
}
}
Y2xhc3MgU29sdXRpb24gewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFN0cmluZyBzID0gIjAwLTQ0ICA0OCA1NTU1IDgzNjEiOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihzb2x1dGlvbihzKSk7CiAgICAgICAgU3RyaW5nIHMyID0gIjAwLTQ0ICA0OCA1NTU1IDgzNjEgeHh4IDEiOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihzb2x1dGlvbihzMikpOwogICAgICAgIFN0cmluZyBzMyA9ICIxMjM0NSI7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKHNvbHV0aW9uKHMzKSk7CiAgICB9CgogICAgcHVibGljIHN0YXRpYyBTdHJpbmcgc29sdXRpb24oU3RyaW5nIHMpIHsKICAgICAgICByZXR1cm4gcy5yZXBsYWNlQWxsKCJbXlxcZF0iLCAiIikucmVwbGFjZUFsbCgiLi4uIiwgIiQwLSIpLnJlcGxhY2VBbGwoIi0kIiwgIiIpOwogICAgfQp9