Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * Return Primary Account Number with a space between each digit group. * * @param pan String * @return String */ public static String prettyPan(String pan) { return pan.replaceAll("(.{4}(?!$))", "$1 ").trim(); } }