title: How to get values of Year,Month and Day from String with help of Regex
body: <p>I am using Android Studio, and I have a <code>date</code> string which could be like this</p>
  
  <pre><code>2018/1/7
  2018/10/7
  2018/1/30
  </code></pre>
  
  <p>And I want to use Regex to extract Year, Month and day from it.
  I have this code:</p>
  
  <pre><code>int[] getAlarmTimeArray() {
          Matcher m = Pattern.compile("(\\d{4})\\/(\\d{1,2})\\/(\\d{1,2})").matcher(date);
          return new int[]{
                           Integer.parseInt(m.group(1)),
                           Integer.parseInt(m.group(2)), 
                           Integer.parseInt(m.group(3))};
      }
  </code></pre>
  
  <p>This code always produces:</p>
  
  <pre><code>java.lang.IllegalStateException: No successful match so far
  </code></pre>
  
  <p>I am sure that the <code>date</code> delivered to the function is good, and I also tried some other patterns, but nothing.</p>
  
  <pre><code>"(\\d{4})\/(\\d{1,2})\/(\\d{1,2})"
  
  "(\\d{4})/(\\d{1,2})/(\\d{1,2})"
  </code></pre>
  
  <p>I tried the first pattern on <a href="https://regex101.com/r/OOO26v/1/" rel="nofollow noreferrer">regex demo</a> and it works fine.</p>
  
  <p>I am not that good using Regex so please help me.</p>