SwatI18N/SwatI18NLocale.php
protected function parseNegativeNotation(
        $string,
        $n_sign = null,
        $n_sign_position = 1
    ) {
        $lc = $this->getLocaleInfo();

        $negative = false;

        if ($n_sign == '') {
            if ($lc['negative_sign'] == '') {
                $negative_sign = '-';
            } else {
                $negative_sign = $lc['negative_sign'];
            }
        } else {
            $negative_sign = $n_sign;
        }

        // filter out all chars except for digits and negative formatting chars
        $char_class = '0-9' . preg_quote($negative_sign, '/');
        if ($n_sign_position === 0) {
            $char_class = '()' . $char_class;
        }
        $exp = '/[^' . $char_class . ']/u';
        $filtered = preg_replace($exp, '', $string);

        if ($filtered != '') {
            if ($filtered[0] === '-' || mb_substr($filtered, -1) === '-') {
                // always allow parsing by negative sign
                $negative = true;
                $string = str_replace($negative_sign, '', $string);
            } elseif (
                $n_sign_position === 0 &&
                $filtered[0] === '(' &&
                mb_substr($filtered, -1) === ')'
            ) {
                // parse parenthetical negative shown as: (5.00)
                $negative = true;
                $string = str_replace(array('(', ')'), '', $string);
            }
        }

        if ($negative) {
            $string = '-' . $string;
        }

        return $string;
    }
protected function parseNegativeNotation(
        $string,
        $n_sign = null,
        $n_sign_position = 1
    ) {
        $lc = $this->getLocaleInfo();

        $negative = false;

        if ($n_sign == '') {
            if ($lc['negative_sign'] == '') {
                $negative_sign = '-';
            } else {
                $negative_sign = $lc['negative_sign'];
            }
        } else {
            $negative_sign = $n_sign;
        }

        // filter out all chars except for digits and negative formatting chars
        $char_class = '0-9' . preg_quote($negative_sign, '/');
        if ($n_sign_position === 0) {
            $char_class = '()' . $char_class;
        }
        $exp = '/[^' . $char_class . ']/u';
        $filtered = preg_replace($exp, '', $string);

        if ($filtered != '') {
            if ($filtered[0] === '-' || mb_substr($filtered, -1) === '-') {
                // always allow parsing by negative sign
                $negative = true;
                $string = str_replace($negative_sign, '', $string);
            } elseif (
                $n_sign_position === 0 &&
                $filtered[0] === '(' &&
                mb_substr($filtered, -1) === ')'
            ) {
                // parse parenthetical negative shown as: (5.00)
                $negative = true;
                $string = str_replace(array('(', ')'), '', $string);
            }
        }

        if ($negative) {
            $string = '-' . $string;
        }

        return $string;
    }
protected function parseNegativeNotation ( $ string , $ n_sign = null , $ n_sign_position = 1 ) { $ lc = $ this -> getLocaleInfo ( ) ; $ negative = false ; if ( $ n_sign == '' ) { if ( $ lc [ 'negative_sign' ] == '' ) { $ negative_sign = '-' ; } else { $ negative_sign = $ lc [ 'negative_sign' ] ; } } else { $ negative_sign = $ n_sign ; } // filter out all chars except for digits and negative formatting chars $ char_class = '0-9' . preg_quote ( $ negative_sign , '/' ) ; if ( $ n_sign_position === 0 ) { $ char_class = '()' . $ char_class ; } $ exp = '/[^' . $ char_class . ']/u' ; $ filtered = preg_replace ( $ exp , '' , $ string ) ; if ( $ filtered != '' ) { if ( $ filtered [ 0 ] === '-' || mb_substr ( $ filtered , - 1 ) === '-' ) { // always allow parsing by negative sign $ negative = true ; $ string = str_replace ( $ negative_sign , '' , $ string ) ; } elseif ( $ n_sign_position === 0 && $ filtered [ 0 ] === '(' && mb_substr ( $ filtered , - 1 ) === ')' ) { // parse parenthetical negative shown as: (5.00) $ negative = true ; $ string = str_replace ( array ( '(' , ')' ) , '' , $ string ) ; } } if ( $ negative ) { $ string = '-' . $ string ; } return $ string ; }
Parses the negative notation for a numeric string formatted in this
locale

@param string $string the formatted string.
@param string $n_sign optional. The negative sign to parse. If not
specified, the negative sign for this locale is
used.
@param integer $n_sign_position optional. The position of the negative
sign in the formatted string. If not
specified, the value 1 is assumed. This
may be used to allow parsing
parenthetical formatted negative values
as used by some currencies.

@return string the formatted string with the negative notation parsed
and normalized into a form readable by intval() and
floatval().
Parses the negative notation for a numeric string formatted in this locale