1. regex with variable
example: find the number and put a parenthese around the number.
output:
a(5265)b
String field = "a5265b"; String result = field.replaceAll("(\d+)", "($1)");