title: PHP: Regex match string not preceded by number or space
body: <p>I've been trying to check if a string value starts with a numerical value or space and act accordingly, but it doesn't seem to be working. Here is my code:</p>
  <pre><code>private static function ParseGamertag( $gamertag )
  {
  
      $safetag = preg_replace( &quot;/[^a-zA-Z0-9\s]+/&quot;, &quot;&quot;, $gamertag ); // Remove all illegal characters : works
      $safetag = preg_replace( &quot;/[\s]+/&quot;, &quot;\s&quot;, $safetag ); // Replace all 1 or more space characters with only 1 space : works
      $safetag = preg_replace( &quot;/\s/&quot;, &quot;%20&quot;, $safetag ); // Encode the space characters : works
  
      if ( preg_match( &quot;/[^\d\s][a-zA-Z0-9\s]*/&quot;, $safetag ) ) // Match a string that does not start with numerical value : not working
          return ( $safetag );
      else
          return ( null );
  
  }
  </code></pre>
  <p>So <code>hiphop112</code> is valid but <code>112hiphip</code> is not valid. <code>0down</code> is not valid.</p>
  <p>The first character <em>must</em> be an alphabetical character <code>[a-zA-Z]</code>.</p>