title: Laravel 5.4 - Validation with Regex
body: <p><strong>Below is my rule for project name:</strong></p>
  
  <pre><code>$this-&gt;validate(request(), [
      'projectName' =&gt; 'required|regex:/(^([a-zA-z]+)(\d+)?$)/u',
  ];
  </code></pre>
  
  <p>I am trying to add the rule such that it must start with a <strong>letter from <code>a-z</code> or <code>A-z</code> and can end with numbers but most not.</strong></p>
  
  <p>Valid values for project name:</p>
  
  <pre><code>myproject123
  myproject
  MyProject
  </code></pre>
  
  <p>Invalid values for project name:</p>
  
  <pre><code>123myproject
  !myproject
  myproject 123
  my project
  my project123
  </code></pre>
  
  <p>I tried my regex online:</p>
  
  <p><a href="https://i.stack.imgur.com/HfNfX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HfNfX.png" alt="enter image description here"></a></p>
  
  <p><a href="https://regex101.com/r/FylFY1/2" rel="noreferrer">https://regex101.com/r/FylFY1/2</a></p>
  
  <p>It should work, but I can pass the validation even with <code>project 123</code>.</p>
  
  <p><em>UPDATE</em>: It actually works, I just tested it in the wrong controller, im sorry... but maybe it will help others nevertheless</p>