title: regular expression not work in android
body: <p>Hi I want to match first name character by character but this make a error , this is my code:</p>
  
  <pre><code>int length = input.length();
  for (int i = 0; i &lt; length; i++){
      char ch = input.charAt(i);
      String regex ="^[_\\s]||[آ-ی]$";
      Matcher matcher = Pattern.compile( regex ).matcher(ch);
  </code></pre>
  
  <p>and this is my complete code:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      EditText editText;
      Button button;
      String input;
      String result;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          editText = (EditText)findViewById(R.id.edt);
          button = (Button)findViewById(R.id.btn);
          button.setOnClickListener(new View.OnClickListener() {
              @SuppressLint("ShowToast")
              @Override
              public void onClick(View v) {
                 input = editText.getText().toString();
                  check_reg();
              }
          });
  
      }
      public  boolean check_reg(){
          int length = input.length();
          for (int i = 0; i &lt; length; i++){
              char ch = input.charAt(i);
              String regex ="^[_\\s]||[آ-ی]$";
              Matcher matcher = Pattern.compile( regex ).matcher(ch);
              if (matcher.find( ))
              {
                  result = matcher.group();
                  Toast.makeText(MainActivity.this, "match", Toast.LENGTH_SHORT).show();
              }
              else
              {
                  Toast.makeText(MainActivity.this, "no match", Toast.LENGTH_SHORT).show();
              }
  
          }
          return false;
      }
  }
  </code></pre>
  
  <p>and this is a image of my problem:</p>
  
  <p><img src="https://i.stack.imgur.com/ALb22.jpg" alt="enter image description here"></p>