How to validate mobile phone number entered?
<pre><code>complete = (Button) findViewById(R.id.complete);
complete.setOnClickListener(new View.OnClickListener() {

        String validNumber = "";

    public void onClick(View v){

        validNumber = phoneNumber.getText().toString();

        if (!validNumber.equals("")){

                final String phoneNumPattern = "^(?=.*[0-9]){10,11}$";  
                Pattern pattern = Pattern.compile(phoneNumPattern);
                Matcher matcher = pattern.matcher(validNumber);     

                 if (matcher.matches() == true){
            Toast.makeText(PhoneNumActivity.this, "Success", Toast.LENGTH_SHORT).show();        
                 }
                 else{
            Toast.makeText(PhoneNumActivity.this, "Failed", Toast.LENGTH_SHORT).show();
                  }
        }
        else{
                 Toast.makeText(PhoneNumActivity.this, "Failed", Toast.LENGTH_SHORT).show();
        }
    }
 });
</code></pre>

<p>I am developing an security apps which user needs to enter a valid mobile phone number, I set the pattern above where user can only enter number with min 10 digit and max 11 digit. But it come out an error </p>

<blockquote>
  <p>java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 13:</p>
</blockquote>

<p>And one more question, can I set the pattern so that the first two digits of the mobile number is <code>01xxxxxxxxxx</code>?</p>
