Project

General

Profile

Revision 76bdcd04

Added by Assos Assos almost 6 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/webform/components/number.inc
815 815
 * This function allows the thousands separator to be optional, but decimal
816 816
 * points must be in the right location.
817 817
 *
818
 * A valid number is:
819
 *   1. optional minus sign.
820
 *   2. optional space.
821
 *   3. the rest of the string can't be just a decimal or blank.
822
 *   4. optional integer portion, with thousands separators.
823
 *   5. optional decimal portion, starting is a decimal separator.
824
 * Don't use preg_quote because a space is a valid thousands separator and
825
 * needs quoting for the 'x' option to preg_match.
826
 *
818 827
 * Based on http://stackoverflow.com/questions/5917082/regular-expression-to-match-numbers-with-or-without-commas-and-decimals-in-text.
819 828
 */
820 829
function webform_number_format_match($value, $point, $separator) {
821
  // A valid number is:
822
  //   1. optional minus sign.
823
  //   2. optional space.
824
  //   3. the rest of the string can't be just a decimal or blank.
825
  //   4. optional integer portion, with thousands separators.
826
  //   5. optional decimal portion, starting is a decimal separator.
827
  // Don't use preg_quote because a space is a valid thousands separator and
828
  // needs quoting for the 'x' option to preg_match.
829 830
  $thousands = $separator ? "\\$separator?" : '';
830 831
  $decimal = "\\$point";
831 832
  return preg_match("/

Also available in: Unified diff