title: Cucumber arity mismatch: trying to bind several matching groups to a single stepdef parameter
body: <p>I'm trying to create a regular expression that will match the following:</p>
  
  <pre><code>Given I'm a user
  Given I am a user
  Given Dylan is a user
  </code></pre>
  
  <p>And this is my step definition:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Given("^(?:(I)'m|(I) am|(.+) is) a user$")
  public void aUserExists(String username) throws Throwable {
  }
  </code></pre>
  
  <p>It's matching what I need, but seems like Cucumber is trying to assign each capturing group in the non-capturing group to a parameter, while I want it to assign just one:</p>
  
  <blockquote>
    <p>cucumber.runtime.CucumberException: Arity mismatch: Step Definition 'hello.MyStepdefs.aUserExists(String) in [...] with pattern [^(?:(I)'m|(I) am|(.+) is) a user$] is declared with 1 parameters. However, the gherkin step has 3 arguments [I, null, null].</p>
  </blockquote>
  
  <p>I'm coming from PHP background and this regular expression worked great with <a href="http://behat.org/" rel="nofollow">Behat</a>. Maybe I'm not getting something about Java regular expressions or Cucumber behavior.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Since all the current answers are having the same problem, I'm updating the question.</p>
  
  <p>I don't want to match a string like:</p>
  
  <pre><code>Given I is a user
  </code></pre>
  
  <p>I want to match <code>I</code> only when it's followed by <code>'m</code> or <code>am</code>. I hope it's not an impossible thing to do with Java regular expressions and Cucumber.</p>