开发者

PHP German Currency Regular Expression

I've been trying all sorts of strange combinations but just can't get my head around Regular Expressions, could somebody help me please. In Germany the , is used instead of a . and a . is used instead of a , e.g. Germen= 10.000,00 English= 10,000.00 I don't need a thousand seperator.

Allowed:

  • 1
  • 1,0
  • 1,00
  • ,5
  • etc...

Not allowed:

  • 1.0
  • 1,000
  • -,5
  • abc
  • 0,0€
  • etc...

Is it pos开发者_开发问答sible to change the format with a Regular Expression so if someone were to enter: 2 or 2,0 it would be changed to 2,00 and if someone where to enter ,5 it would be changed to 0,50?


Work with floats in php depends on your locale. You might want to see Manual

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜