|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
eingfoan Smarty n00b
Joined: 08 Feb 2005 Posts: 4
|
Posted: Thu Feb 10, 2005 10:17 am Post subject: Smarty Validate is number not complient with comma decimal |
|
|
hi all,
i got a real small problem !
due to the affect that i am not aware of regex (what is really anoying)
could anybody help me to hack isnumber of smarty validate to take comma as decimalpoint TOO?
the actual routine is
Code: |
if(strlen($value) == 0)
return $empty;
return preg_match('!^\d+(\.\d+)?$!', $value);
|
how to get it working with decimal commans and points?
thx in advance chris |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Feb 10, 2005 2:33 pm Post subject: |
|
|
change \. to [\.,]
so the resulting change is:
return preg_match('!^\d+([\.,]\d+)?$!', $value); |
|
Back to top |
|
eingfoan Smarty n00b
Joined: 08 Feb 2005 Posts: 4
|
Posted: Thu Feb 10, 2005 4:04 pm Post subject: |
|
|
thanks very much !!!
btw do u know a good source for learning regex?
sincerely chris |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Feb 10, 2005 5:06 pm Post subject: |
|
|
Pick up Mastering Regular Expressions (Friedl) from O'Reilly, or google around for perl regular expression tutorials. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Feb 10, 2005 5:24 pm Post subject: |
|
|
I raised my knowledge of regexs quite a lot just by reading the PHP manual. Still that experience paled next to reading Mastering Regular Expressions which is a rigorous and thorough examination of the topic. Unless regexs are somehow changed in a fundamental way, I'll never need another book on the subject. Highly Recommended. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|