Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > [regex] Validare numero di telefono
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[regex] Validare numero di telefono

Ciao a tutti,
qualcuno mi sa aiutare? Sto cercando di scrivere una regex che validi una stringa del tipo +39123456789 (insomma un più seguito da una serie di numeri)...
io ho provato con una cosa tipo

code:
\+[\d]*


ma questo mi valida anche stringhe del tipo +abcde12345 che non è quello che voglio...

__________________
http://www.twitter.com/0m4r

07-11-2005 15:05
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ripe
- up in the mountains -

User info:
Registered: Jun 2002
Posts: 9469 (1.09 al dì)
Location: Cinisellooo
Corso: TICO TICO
Anno: Primo
Time Online: 61 Days, 2:33:39 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

una roba del genere...?

\+[0-9]*

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»

07-11-2005 15:54
Click Here to See the Profile for ripe Click Here to See the Blog of ripe Click here to Send ripe a Private Message Find more posts by ripe Add ripe to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ho provato anche in quel modo, ma ho lo stesso risultato della regex che ho postato io... cioè mi prende come valide stringhe del tipo +123ssd15s4ds54, cioè composte sia da numeri che da lettere, ma a me servono solo numeri...
ad ogni modo grazie lo stesso

__________________
http://www.twitter.com/0m4r

07-11-2005 16:08
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Tu a priori sai di quante cifre è composto il numero no?
Quindi suggerirei:

^[\+][0-9]{min,max}

dove min è il numero minimo di numero dopo il + e max e quello massimo.

L'espressione filta la seguente lista correttamente:

+392384747
+sadas4949
+033ssda
2344
asdf
+3445ass345
+as23445



Attenzione che a seconda del linguaggio usato, potrebbe essere necessario escapare le graffe (come ad esempio con grep su linux).

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

07-11-2005 16:34
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

grazie DeepBlue,
ma forse non mi sono spiegato bene io, io voglio che sia dato esito positivo SOLO se la stringa è composta da un "+" e da una serie di numeri (che come giustamente hai detto te non so quanti saranno), quindi +abc123 e 123456 NON devono essere corrette, mentre +123456 E' CORRETTA

edit:

code:
^[\+][0-9]*$

questa funziona (quasi) solo che considera corette anche stringe composte solo dal "+"... consigli?

__________________
http://www.twitter.com/0m4r

Last edited by 0m4r on 07-11-2005 at 16:41

07-11-2005 16:38
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

^[\+]{1}[0-9]*$


strano comunque, a me funziona anche senza {1}

Ma con cosa le crei? Php? perl? o che?

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

Last edited by DeepBlue on 07-11-2005 at 16:53

07-11-2005 16:51
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
giulio
.no title at all.

User info:
Registered: Jul 2003
Posts: 153 (0.02 al dì)
Location: Earth
Corso: Once upon a time...
Anno:
Time Online: 8 Days, 21:56:12 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by 0m4r
edit:
code:
^[\+][0-9]*$

questa funziona (quasi) solo che considera corette anche stringe composte solo dal "+"... consigli? [/B]


Prova:

"^[\+][0-9]\+$"

l'asterisco matcha 0 o piu' occorrenze del carattere precedente, mentre il "+" matcha una o piu' occorrenze.

07-11-2005 16:54
Click Here to See the Profile for giulio Click here to Send giulio a Private Message Find more posts by giulio Add giulio to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

sto creando delle form con cocoon... anche io avevo pensato all'{1}, ora lo testo e poi ti faccio sapere

ri-ri-edit:
FUNZIONA
almeno sembra, perchè io non ho messo lo slash davanti al + prima del $, se lo mettessi intenderei il carattere "+" o sbaglio?!

code:
^[\+][0-9]+$

grazie Giulio!

__________________
http://www.twitter.com/0m4r

Last edited by 0m4r on 07-11-2005 at 17:03

07-11-2005 16:55
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 12:35.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.130 seconds (58.39% PHP - 41.61% MySQL) con 25 query.