Skip to content

Instantly share code, notes, and snippets.

@stephaneIBANEZ
Created February 27, 2017 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephaneIBANEZ/9095c283c9586403c9888abd62436bca to your computer and use it in GitHub Desktop.
Save stephaneIBANEZ/9095c283c9586403c9888abd62436bca to your computer and use it in GitHub Desktop.
javascript input string cleanup only ALPHA
/*
* This file is part of the Inserm Radico package.
*
* @author Stéphane IBANEZ <stephane.ibanez@aezan.com>
*
* This class is used for cleaning input strings
* 1 - ' is replace by a sapce
* 2 - All non alpha characters are removed
* 3 - "-" is replaced by a space
*/
var reg = new RegExp(/[^A-Za-záàâäãåçéèêëíìîïñóòôöõúùûüýÿæœÁÀÂÄÃÅÇÉÈÊËÍÌÎÏÑÓÒÔÖÕÚÙÛÜÝŸÆŒ\-\s]/gi);
// 1 //
$familyName = $familyName.replace(/[\'\-]/gmi, " ");
$givenName = $givenName.replace(/[\'\-]/gmi, " ");
// 2 //
$familyName = $familyName.replace(reg, "");
$givenName = $givenName.replace(reg, "");
// 3 //
$familyName = $familyName.replace(/\s/gi, "-");
$givenName = $givenName.replace(/\s/gi, "-");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment