Skip to content

replaceCharactersNotInPattern

elcapo edited this page Oct 16, 2014 · 3 revisions

replaceCharactersNotInPattern replaces unwanted characters from a string with a given character.

An example:

  • We have this string: 1!2/3·A|B@C#
  • This are the characters we accept: 123ABC
  • This is the character we want to replace extra characters with: 0
  • The example would return: 102030A0B0C0

Usage

/* MySQL */
SELECT replaceCharactersNotInPattern(
           '1!2/3·A|B@C#',
           '123ABC',
           '0' ); /* Returns 102030A0B0C0 */
/* JavaScript */
var cleanString = replaceCharactersNotInPattern(
           '1!2/3·A|B@C#',
           '123ABC',
           '0' ); /* cleanString = 102030A0B0C0 */
/* PHP */
$cleanString = replaceCharactersNotInPattern(
           '1!2/3·A|B@C#',
           '123ABC',
           '0' ); /* $cleanString = 102030A0B0C0 */

Return values

  • [string] - After replacing unwanted characters with the new one.

Category

This function is part of the [International Bank Account Numbers (IBAN)](International Bank Account Numbers (IBAN)) package.

SEPA validations

  • [International Bank Account Numbers (IBAN)](International Bank Account Numbers (IBAN))

Spanish validations

Helpers

  • [Common functions](Common functions)
Clone this wiki locally