title: replace regular expression with its input mask ( 200 kind )
body: <p>For records:</p>
  
  <p><strong>X</strong> means anything</p>
  
  <p><strong>Y</strong> means year</p>
  
  <p><strong>M</strong> means month</p>
  
  <p><strong>N</strong> means numeric</p>
  
  <p><strong>A</strong> means alphabet</p>
  
  <p>For example:</p>
  
  <p>my input mask from database is like this:</p>
  
  <pre><code>XXXYMXXXXXA
  </code></pre>
  
  <p>and my input is:</p>
  
  <pre><code>39JY412345O
  </code></pre>
  
  <p>i want check this input is valid or invalid but i can't check it with mask, I want replace mask with regular expression like this for its input mask:</p>
  
  <pre><code> /^.{3}Y[0-9]{1}.{5}[a-zA-Z]{1}$/
  </code></pre>
  
  <p>I don't have regular expression, I have input mask only.I have input validation and it use regular expression for checking valid or invalid inputs. I should replace regular expression with my input mask ( 200 kind of input mask ) and I use its regular expression for validation</p>
  
  <p>I need to write a method that translates from an input mask (such as "XXXYMXXXXXA") to a regex in the java.lang.regex.Pattern format (such as ".{3}Y[0-9]{1}.{5}[a-zA-Z]{1}")</p>
  
  <p>This is my method code: ( <strong>but I want best practice for this solution</strong> )</p>
  
  <pre><code>private String replaceAll(String pattern, String value, String replaceValue) {
      String str = value;
      str = str.replaceAll(pattern, replaceValue.concat("{").concat("1").concat("}"));
      return str;
  }
  </code></pre>
  
  <p>and method calls:</p>
  
  <pre><code>String anything = "[Xx]";
  String alphabet = "[Aa]";
  String number = "[Nn]";
  String word = getName();
  
  word = replaceAll(anything, word, ".");
  word = replaceAll(alphabet, word, "[A-Za-z]");
  word = replaceAll(number, word, "[0-9]");
  </code></pre>