Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created February 16, 2012 14:43
Show Gist options
  • Select an option

  • Save daGrevis/1845355 to your computer and use it in GitHub Desktop.

Select an option

Save daGrevis/1845355 to your computer and use it in GitHub Desktop.
Regex for i18n name with spaces
<?php
$regex = '/^\pL+( \pL+)*$/uD';
$values = array(
'John Smith',
'Jānis Bērziņš',
'Hack3r',
'I like periods.',
);
foreach ($values as $value) {
var_dump((boolean)preg_match($regex, $value));
}
@daGrevis

Copy link
Copy Markdown
Author

Output:

bool(true)
bool(true)
bool(false)
bool(false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment