Created
February 27, 2017 09:02
-
-
Save stephaneIBANEZ/9095c283c9586403c9888abd62436bca to your computer and use it in GitHub Desktop.
javascript input string cleanup only ALPHA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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