-
Notifications
You must be signed in to change notification settings - Fork 4
respectsDocPattern
elcapo edited this page Oct 16, 2014
·
5 revisions
respectsDocPattern
tests a string against a regexp pattern. Actually, this function has been written as a helper for isValidNIFFormat
, isValidNIEFormat
and isValidCIFFormat
, but it can still be called directly.
/* MySQL */
SELECT respectsDocPattern( '33576428Q',
'[KLM0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-Z]' ); /* Returns 1 */
SELECT respectsDocPattern( '1A1A1A1A',
'[KLM0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-Z]' ); /* Returns 0 */
/* JavaScript */
var isValid = respectsDocPattern( '33576428Q',
'[KLM0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-Z]' ); /* Returns 1 */
var isValid = respectsDocPattern( '1A1A1A1A',
'[KLM0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-Z]' ); /* Returns 0 */
/* PHP */
$isValid = respectsDocPattern( '33576428Q',
'[KLM0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-Z]' ); /* Returns 1 */
$isValid = respectsDocPattern( '1A1A1A1A',
'[KLM0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-Z]' ); /* Returns 0 */
-
1
- If the string fits the pattern. -
0
- Otherwise.
This function is part of the NIF, NIE & CIF package.
Go back home!
SEPA validations
- [International Bank Account Numbers (IBAN)](International Bank Account Numbers (IBAN))
Spanish validations
- NIF, NIE & CIF
- [Spanish Bank Accounts](Spanish Bank Accounts)
Helpers
- [Common functions](Common functions)