Android EditText check assistance
<p>I have an editText field for which I want check that it meets with certain criteria, basically it has to contain 2ints and 3 strings, how can I check this before adding the element.</p>

<pre><code> EditText.getText().toString();
</code></pre>

<p>could I add a check that does comething like this</p>

<pre><code>public boolean checkString(String StringPassed) {

   String s = StringPassed;
if(s.length == 5){
  boolean hasString = false;
  boolean hasInt = false;
  String letters = s.substring(0, 2);
  Pattern p = Pattern.compile("[a-zA-Z]");
  Matcher m = p.matcher(letters);
  if (m.matches()) {
    hasString = true;
  }
  String numbers=s.substring(2,5);
  try {
    int num = Integer.parseInt(numbers);
    String n = num + "";
    if (num &gt; 0 &amp;&amp; n.length() == 3)
        hasInt = true;
  } catch (Exception e) {
  }
  if (hasInt &amp;&amp; hasString) {
   return true;
  }
 }else{
  return false;
 }
return false;
}
</code></pre>

<p>I then have a method which will say</p>

<pre><code>public void addString() {

String StringPassed =  EditTextName.getString().toString();
checkString(String StringPassed);

if (StringPassed() == false) {
Display Toast;
}
else {
      add;
     }
}
</code></pre>
