Java tutorial
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { CharSequence inputStr = "quit"; String patternStr = "q"; String replacementStr = "s"; Pattern pattern = Pattern.compile(patternStr); Matcher matcher = pattern.matcher(inputStr); String output = matcher.replaceAll(replacementStr); } }