开发者

PHP German Currency Regular Expression

开发者 https://www.devze.com 2023-02-15 03:56 出处:网络
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 inste

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

精彩评论

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