Deprecated: Return type of AWeberCollection::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 246

Deprecated: Return type of AWeberCollection::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 252

Deprecated: Return type of AWeberCollection::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 244

Deprecated: Return type of AWeberCollection::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 245

Deprecated: Return type of AWeberCollection::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 267

Deprecated: Return type of AWeberCollection::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 275

Deprecated: Return type of AWeberCollection::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 271

Deprecated: Return type of AWeberCollection::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 283

Deprecated: Return type of AWeberCollection::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 279

Deprecated: Return type of AWeberCollection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_collection.php on line 293

Deprecated: Return type of AWeberEntryDataArray::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 22

Deprecated: Return type of AWeberEntryDataArray::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 26

Deprecated: Return type of AWeberEntryDataArray::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 30

Deprecated: Return type of AWeberEntryDataArray::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 36

Deprecated: Return type of AWeberEntryDataArray::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 18

Deprecated: Return type of AWeberEntryDataArray::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 44

Deprecated: Return type of AWeberEntryDataArray::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 52

Deprecated: Return type of AWeberEntryDataArray::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 48

Deprecated: Return type of AWeberEntryDataArray::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 56

Deprecated: Return type of AWeberEntryDataArray::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/blossomthemes-email-newsletter/includes/libs/aweber/aweber_entry_data_array.php on line 40

Deprecated: Return type of Wppr_Recursive_Filter::getChildren() should either be compatible with RecursiveFilterIterator::getChildren(): ?RecursiveFilterIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/wp-product-review/class-wppr-recursive-filter.php on line 51

Deprecated: Return type of Wppr_Recursive_Filter::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/wp-product-review/class-wppr-recursive-filter.php on line 40

Deprecated: Optional parameter $class_div declared before required parameter $heading_type is implicitly treated as a required parameter in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/wp-product-review/includes/functions.php on line 245

Deprecated: Optional parameter $class_div declared before required parameter $heading_type is implicitly treated as a required parameter in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/wp-product-review/includes/functions.php on line 255

Deprecated: version_compare(): Passing null to parameter #2 ($version2) of type string is deprecated in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/wp-product-review/vendor/codeinwp/themeisle-sdk/load.php on line 31

Deprecated: version_compare(): Passing null to parameter #2 ($version2) of type string is deprecated in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/wp-product-review/vendor/codeinwp/themeisle-sdk/load.php on line 36

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/amazon-auto-links/include/core/main/option/AmazonAutoLinks_Option.php on line 779

Deprecated: dirname(): Passing null to parameter #1 ($path) of type string is deprecated in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-content/plugins/amazon-auto-links/include/core/component/template/option/AmazonAutoLinks_TemplateOption.php on line 378

Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u276665811/domains/massimopetrossi.com/public_html/blog/wp-includes/formatting.php on line 2827
Una REGEX per validare il Codice Fiscale – massimo petrossi blog

Una REGEX per validare il Codice Fiscale

Nel lavoro di consulente di comunicazione, ci si trova anche a rivedere siti web per migliorarli e perfezionarli, rendendone l’uso il più semplice possibile sia dal lato dell’utente, sia dal lato del gestore. A volte questo significa rendere più snello e veloce un sito, a volte significa “obbligare” l’utente a seguire un percorso. Un esempio?

Recentemente mi sono trovato di fronte all’esigenza di modificare un modulo di registrazione ad un sito web, inserendo un sistema di validazione del codice fiscale nell’apposito campo. Come si comprende facilmente, non si può lasciare all’utente la possibilità di scrivere caratteri a caso, per le ovvie implicazioni fiscali: ci sono infatti regole precise per definire il codice fiscale di una persona.

Struttura del codice fiscale italiano

Cercando in rete, ho trovato queste due espressioni regolari (REGEX), che ritrascrivo qui per comodità mia, e utilità di tutti:

La più semplice è

^[A-Z]{6}[0-9]{2}[A-Z][0-9]{2}[A-Z][0-9]{3}[A-Z]$

La più particolareggiata, che tiene conto delle lettere effettivamente utilizzate per il mese di nascita, è

^[a-zA-Z]{6}[0-9]{2}[abcdehlmprstABCDEHLMPRST]{1}[0-9]{2}([a-zA-Z]{1}[0-9]{3})[a-zA-Z]{1}$
/*tra le parentesi tonde vi è l'identificativo del comune di nascita (codice catastale). Le lettere elencate (abcd ecc.) indicano il mese di nascita mentre l'ultima lettera è quella di controllo.*/

Ringrazio newbie e nightfly83 dal forum di html.it, in cui ho trovato queste espressioni.

Rispondi

%d blogger hanno fatto clic su Mi Piace per questo: