var pattern =/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;

You can append any String to a StringBuffer by using its append method, eg

StringBuffer sb = new StringBuffer("pattern is ");
String pattern = "/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/"; // will need to escape the \ chars as \
sb.append(pattern);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.