Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.www.php > #20111
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Alessandro Pellizzari <shuriken@amiran.it> |
| Newsgroups | it.comp.www.php |
| Subject | Re: espressione regolare |
| Date | 28 Nov 2015 22:01:55 GMT |
| Lines | 31 |
| Message-ID | <dbumijFml5bU1@mid.individual.net> (permalink) |
| References | <2015112817284421718@mynewsgate.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net egdNP/nJH22RUQsVzNKXegqeaL1yElrWU56IWxi74Kzs9tI3Y= |
| Cancel-Lock | sha1:eFEUZIP6vWkNQKSkIGGx2PdrM9o= |
| User-Agent | Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) |
| Xref | csiph.com it.comp.www.php:20111 |
Show key headers only | View raw
Il Sat, 28 Nov 2015 17:28:44 +0000, Halnow ha scritto:
> volevo ottenere un'espressione in grado di verificare se l'input utente
> è composto da 1 a 10 cifre seguito da due cifre decimali...
> 0,00 1,20 12,53 1526,60 etc...
La parte decimale è facoltativa o obbligatoria? Dalla tua RE sembra
facoltativa.
> if (!preg_match("/^d{1,10}(\,\d{2})?$/",$input_utente)) {
Sul primo d manda il backslash: \d
Sulla virtola non serve il backslash: (,\d{2}...)
preg_match restituisce 0 se non matcha e false se c'è un errore nella
regexp. Se casti tutto a bool non saprai mai se c'è stato un errore o se
non ha trovato il match. L'if giusto è
$res = preg_match...;
if (false === $res) {
// errore
} else if (0 === $res) {
// no match
} else {
// match
}
Bye.
Back to it.comp.www.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
espressione regolare "Halnow" <21718invalid@mynewsgate.net> - 2015-11-28 17:28 +0000
Re: espressione regolare Alessandro Pellizzari <shuriken@amiran.it> - 2015-11-28 22:01 +0000
Re: espressione regolare Alessandro Pellizzari <shuriken@amiran.it> - 2015-11-28 22:03 +0000
Re: espressione regolare "Halnow" <21718invalid@mynewsgate.net> - 2015-11-29 09:10 +0000
Re: espressione regolare Alessandro Pellizzari <shuriken@amiran.it> - 2015-11-29 09:21 +0000
Re: espressione regolare "Halnow" <21718invalid@mynewsgate.net> - 2015-11-29 11:40 +0000
csiph-web