separare lettere da numeri
Moderatore: Moderatori
-
- Messaggi: 3616
- Iscritto il: sabato 7 febbraio 2004, 1:00
- Località: Roma
- Contatta:
separare lettere da numeri
Ciao a tutti
Questa funzione personalizzata ricorsiva inserisce un trattino separatore tra lettere e numeri.
A me è servita per ordinare un campo codice del tipo:
abd023ace-12
il risultato della funzione sarà:
ABD-023-ACE-12
(notare che eventuali trattini già presenti, verranno mantenuti)
Questa funzione personalizzata ricorsiva inserisce un trattino separatore tra lettere e numeri.
A me è servita per ordinare un campo codice del tipo:
abd023ace-12
il risultato della funzione sarà:
ABD-023-ACE-12
(notare che eventuali trattini già presenti, verranno mantenuti)
Codice: Seleziona tutto
/*
DashInsert Custom Function
Type: Recursive
Author: Daniele Raybaudi
Format: DashInsert ( text )
Result: text
Returns the given text with dashes between numbers and chars
01/15/2006
*/
Let([
modifiedText = Trim ( Upper (text ) ) ;
char = Middle ( modifiedText ; 1 ; 1 );
charType = If(Length ( Filter ( char ; "0123456789" ) ) ;1;0);
nextChar = Middle ( modifiedText ; 2 ; 1 );
nextCharType = If(Length ( Filter ( nextChar ; "0123456789" ) );1;0);
nextText = Right ( modifiedText ; Length ( modifiedText ) - 1 )
];
Case(
Length ( modifiedText );
Case(
charType = nextCharType or nextChar = "" or nextChar = "-" or char = "-"; char;
charType ≠ nextCharType;char &"-")
&
DashInsert ( nextText );
""
)
)
Raybaudi FMP 12 Adv. Windows XP SP3