title: Regex for names with special characters (Unicode)
body: <p>Okay, I have read about regex all day now, and still don't understand it properly. What i'm trying to do is validate a name, but the functions i can find for this on the internet only use <code>[a-zA-Z]</code>, leaving characters out that i need to accept to.</p>
  
  <p>I basically need a regex that checks that the name is at least two words, and that it does not contain numbers or special characters like <code>!"#¤%&amp;/()=...</code>, however the words can contain characters like æ, é, Â and so on...</p>
  
  <p>An example of an accepted name would be: "John Elkjærd" or "André Svenson"<br />An non-accepted name would be: "<strong>Hans</strong>", "H<b>4</b>nn<b>3</b> Andersen" or "Martin Henriksen<b>!</b>"</p>
  
  <p>If it matters i use the javascript <code>.match()</code> function client side and want to use php's <code>preg_replace()</code> only "in negative" server side. (removing non-matching characters).</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p><strong>Update:</strong><br />
  Okay, thanks to <a href="https://stackoverflow.com/questions/5963228/regex-for-names-with-special-characters/5963425#5963425">Alix Axel's answer</a> i have the important part down, the server side one.</p>
  
  <p>But as the page from <a href="https://stackoverflow.com/questions/5963228/regex-for-names-with-special-characters/5963334#5963334">LightWing's answer</a> suggests, i'm unable to find anything about unicode support for javascript, so i ended up with half a solution for the client side, just checking for at least two words and minimum 5 characters like this:</p>
  
  <pre><code>if(name.match(/\S+/g).length &gt;= minWords &amp;&amp; name.length &gt;= 5) {
    //valid
  }
  </code></pre>
  
  <p>An alternative would be to specify all the unicode characters as suggested in <a href="https://stackoverflow.com/questions/5963228/regex-for-names-with-special-characters/5963417#5963417">shifty's answer</a>, which i might end up doing something like, along with the solution above, but it is a bit unpractical though.</p>