admin管理员组

文章数量:1334133

My current regex format allow only number, including positive, negative, and floating decimal.

"regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/,

How to allow (add) dollar and ma in my current regex format?

UPDATES:

html

<input type="text" name="amt[]" placeholder="0.00" size="10" id="validation-required"
  class="input-unstyled input-sep validate[required, custom[price]]">

jquery validation

(function($){
    $.fn.validationEngineLanguage = function(){
    };
    $.validationEngineLanguage = {
        newLang: function(){
            $.validationEngineLanguage.allRules = {
                "required": { // Add your regex rules here, you can take telephone as an example
                    "regex": "none",
                    "alertText": "* This field is required",
                    "alertTextCheckboxMultiple": "* Please select an option",
                    "alertTextCheckboxe": "* This checkbox is required",
                    "alertTextDateRange": "* Both date range fields are required"
                },
                "dateRange": {
                    "regex": "none",
                    "alertText": "* Invalid ",
                    "alertText2": "Date Range"
                },
                "dateTimeRange": {
                    "regex": "none",
                    "alertText": "* Invalid ",
                    "alertText2": "Date Time Range"
                },
                "minSize": {
                    "regex": "none",
                    "alertText": "* Minimum ",
                    "alertText2": " characters allowed"
                },
                "maxSize": {
                    "regex": "none",
                    "alertText": "* Maximum ",
                    "alertText2": " characters allowed"
                },
                                "groupRequired": {
                    "regex": "none",
                    "alertText": "* You must fill one of the following fields"
                },
                "min": {
                    "regex": "none",
                    "alertText": "* Minimum value is "
                },
                "max": {
                    "regex": "none",
                    "alertText": "* Maximum value is "
                },
                "past": {
                    "regex": "none",
                    "alertText": "* Date prior to "
                },
                "future": {
                    "regex": "none",
                    "alertText": "* Date past "
                },     
                "maxCheckbox": {
                    "regex": "none",
                    "alertText": "* Maximum ",
                    "alertText2": " options allowed"
                },
                "minCheckbox": {
                    "regex": "none",
                    "alertText": "* Please select ",
                    "alertText2": " options"
                },
                "equals": {
                    "regex": "none",
                    "alertText": "* Fields do not match"
                },
                "creditCard": {
                    "regex": "none",
                    "alertText": "* Invalid credit card number"
                },
                "phone": {
                    // credit: jquery.h5validate.js / orefalo
                    "regex": /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
                    "alertText": "* Invalid phone number"
                },
                "email": {
                    // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin /
                    "regex": /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
                    "alertText": "* Invalid email address"
                },
                "integer": {
                    "regex": /^[\-\+]?\d+$/,
                    "alertText": "* Not a valid integer"
                },
                "price": {
                    // Number, including positive, negative, and floating decimal. credit: orefalo
                    "regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/,
                    "alertText": "* Invalid floating decimal number"
                },
                "date": {
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
                    "alertText": "* Invalid date, must be in YYYY-MM-DD format"
                },
                "ipv4": {
                    "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
                    "alertText": "* Invalid IP address"
                },
                "url": {
                    "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
                    "alertText": "* Invalid URL"
                },
                "onlyNumberSp": {
                    "regex": /^[0-9\ ]+$/,
                    "alertText": "* Numbers only"
                },
                "onlyLetterSp": {
                    "regex": /^[a-zA-Z\ \']+$/,
                    "alertText": "* Letters only"
                },
                "onlyLetterNumber": {
                    "regex": /^[0-9a-zA-Z]+$/,
                    "alertText": "* No special characters allowed"
                },
                // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
                "ajaxUserCall": {
                    "url": "ajaxValidateFieldUser",
                    // you may want to pass extra data on the ajax call
                    "extraData": "name=eric",
                    "alertText": "* This user is already taken",
                    "alertTextLoad": "* Validating, please wait"
                },
                                "ajaxUserCallPhp": {
                    "url": "phpajax/ajaxValidateFieldUser.php",
                    // you may want to pass extra data on the ajax call
                    "extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    "alertTextOk": "* This username is available",
                    "alertText": "* This user is already taken",
                    "alertTextLoad": "* Validating, please wait"
                },
                "ajaxNameCall": {
                    // remote json service location
                    "url": "ajaxValidateFieldName",
                    // error
                    "alertText": "* This name is already taken",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    "alertTextOk": "* This name is available",
                    // speaks by itself
                    "alertTextLoad": "* Validating, please wait"
                },
                                 "ajaxNameCallPhp": {
                            // remote json service location
                            "url": "phpajax/ajaxValidateFieldName.php",
                            // error
                            "alertText": "* This name is already taken",
                            // speaks by itself
                            "alertTextLoad": "* Validating, please wait"
                        },
                "validate2fields": {
                    "alertText": "* Please input HELLO"
                },
                    //tls warning:homegrown not fielded
                "dateFormat":{
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
                    "alertText": "* Invalid Date"
                },
                //tls warning:homegrown not fielded
                                "dateTimeFormat": {
                        "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
                    "alertText": "* Invalid Date or Date Format",
                    "alertText2": "Expected Format: ",
                    "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM or ",
                    "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
                    }
            };

        }
    };

    $.validationEngineLanguage.newLang();

})(jQuery);

My current regex format allow only number, including positive, negative, and floating decimal.

"regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/,

How to allow (add) dollar and ma in my current regex format?

UPDATES:

html

<input type="text" name="amt[]" placeholder="0.00" size="10" id="validation-required"
  class="input-unstyled input-sep validate[required, custom[price]]">

jquery validation

(function($){
    $.fn.validationEngineLanguage = function(){
    };
    $.validationEngineLanguage = {
        newLang: function(){
            $.validationEngineLanguage.allRules = {
                "required": { // Add your regex rules here, you can take telephone as an example
                    "regex": "none",
                    "alertText": "* This field is required",
                    "alertTextCheckboxMultiple": "* Please select an option",
                    "alertTextCheckboxe": "* This checkbox is required",
                    "alertTextDateRange": "* Both date range fields are required"
                },
                "dateRange": {
                    "regex": "none",
                    "alertText": "* Invalid ",
                    "alertText2": "Date Range"
                },
                "dateTimeRange": {
                    "regex": "none",
                    "alertText": "* Invalid ",
                    "alertText2": "Date Time Range"
                },
                "minSize": {
                    "regex": "none",
                    "alertText": "* Minimum ",
                    "alertText2": " characters allowed"
                },
                "maxSize": {
                    "regex": "none",
                    "alertText": "* Maximum ",
                    "alertText2": " characters allowed"
                },
                                "groupRequired": {
                    "regex": "none",
                    "alertText": "* You must fill one of the following fields"
                },
                "min": {
                    "regex": "none",
                    "alertText": "* Minimum value is "
                },
                "max": {
                    "regex": "none",
                    "alertText": "* Maximum value is "
                },
                "past": {
                    "regex": "none",
                    "alertText": "* Date prior to "
                },
                "future": {
                    "regex": "none",
                    "alertText": "* Date past "
                },     
                "maxCheckbox": {
                    "regex": "none",
                    "alertText": "* Maximum ",
                    "alertText2": " options allowed"
                },
                "minCheckbox": {
                    "regex": "none",
                    "alertText": "* Please select ",
                    "alertText2": " options"
                },
                "equals": {
                    "regex": "none",
                    "alertText": "* Fields do not match"
                },
                "creditCard": {
                    "regex": "none",
                    "alertText": "* Invalid credit card number"
                },
                "phone": {
                    // credit: jquery.h5validate.js / orefalo
                    "regex": /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
                    "alertText": "* Invalid phone number"
                },
                "email": {
                    // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground./email_address_validation/
                    "regex": /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
                    "alertText": "* Invalid email address"
                },
                "integer": {
                    "regex": /^[\-\+]?\d+$/,
                    "alertText": "* Not a valid integer"
                },
                "price": {
                    // Number, including positive, negative, and floating decimal. credit: orefalo
                    "regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/,
                    "alertText": "* Invalid floating decimal number"
                },
                "date": {
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
                    "alertText": "* Invalid date, must be in YYYY-MM-DD format"
                },
                "ipv4": {
                    "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
                    "alertText": "* Invalid IP address"
                },
                "url": {
                    "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
                    "alertText": "* Invalid URL"
                },
                "onlyNumberSp": {
                    "regex": /^[0-9\ ]+$/,
                    "alertText": "* Numbers only"
                },
                "onlyLetterSp": {
                    "regex": /^[a-zA-Z\ \']+$/,
                    "alertText": "* Letters only"
                },
                "onlyLetterNumber": {
                    "regex": /^[0-9a-zA-Z]+$/,
                    "alertText": "* No special characters allowed"
                },
                // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
                "ajaxUserCall": {
                    "url": "ajaxValidateFieldUser",
                    // you may want to pass extra data on the ajax call
                    "extraData": "name=eric",
                    "alertText": "* This user is already taken",
                    "alertTextLoad": "* Validating, please wait"
                },
                                "ajaxUserCallPhp": {
                    "url": "phpajax/ajaxValidateFieldUser.php",
                    // you may want to pass extra data on the ajax call
                    "extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    "alertTextOk": "* This username is available",
                    "alertText": "* This user is already taken",
                    "alertTextLoad": "* Validating, please wait"
                },
                "ajaxNameCall": {
                    // remote json service location
                    "url": "ajaxValidateFieldName",
                    // error
                    "alertText": "* This name is already taken",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    "alertTextOk": "* This name is available",
                    // speaks by itself
                    "alertTextLoad": "* Validating, please wait"
                },
                                 "ajaxNameCallPhp": {
                            // remote json service location
                            "url": "phpajax/ajaxValidateFieldName.php",
                            // error
                            "alertText": "* This name is already taken",
                            // speaks by itself
                            "alertTextLoad": "* Validating, please wait"
                        },
                "validate2fields": {
                    "alertText": "* Please input HELLO"
                },
                    //tls warning:homegrown not fielded
                "dateFormat":{
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
                    "alertText": "* Invalid Date"
                },
                //tls warning:homegrown not fielded
                                "dateTimeFormat": {
                        "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
                    "alertText": "* Invalid Date or Date Format",
                    "alertText2": "Expected Format: ",
                    "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM or ",
                    "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
                    }
            };

        }
    };

    $.validationEngineLanguage.newLang();

})(jQuery);
Share Improve this question edited Mar 17, 2013 at 15:44 catherine asked Mar 17, 2013 at 15:16 catherinecatherine 22.8k15 gold badges64 silver badges88 bronze badges 3
  • 2 Can we focus the ments here on solving the problem instead of bickering about whether this is a real question or not, and this tiresome "what have you tried" nonsense. – Kev Commented Mar 17, 2013 at 15:45
  • 1 @Kev Out of interest: I do not follow meta that closely... when/where has "what have you tried" been declared nonsense? – Tomalak Commented Mar 17, 2013 at 16:04
  • @Tomalak - one or two maybe fine if asked constructively, but the ments I've deleted descended into noise. – Kev Commented Mar 17, 2013 at 16:08
Add a ment  | 

4 Answers 4

Reset to default 3

If you want reserved characters like $, ^ and so on to match in your Regex, just escape them with a backslash, for example \$.

"regex": /^[-+]?(([0-9]+)(.,)?|(.,)?)$/,

Your current regex is a little over-plicated. I understand you want to match an optional dollar sign, then a thousand-separated number, optionally with two decimal places. I'm going to assume you don't actually want the + or - signs and that you only want decimal points, and that they are just from what you copy-pasted from some tutorial.

Try this:

/^\$?[1-9]\d?(?:,\d{3})*(?:\.\d{2})?$/

Explanation of this Regex

Here is another one,

/(\$|€|£|¥)([-,._ ]?\d{1,3})+/

Results i got from a huge string that was fetched from multible images,

€67
€6 72
€3 035
€ 328
€29.90
€29940
€1 631
€ 29.940
€68
€3017
€3.017
€ 3.017
€ 164
€96
€68
€ 3.735
€0
€ 14,970
€14.970
€ 14.970
€14.970
€ 3.735
€3.735
€0
€ 3,017
€3.017
€61.692
€166
€1.303
€96
€ 328
€ 68
€827
€33 67
€33.675
€33.875
€14970
€14970
€3.735
€33.675
€33.675
€33.675
€33.675
€362
€ 33.675
€3.266
€2.904
€362
€362
€3.283
€ 33.675
€0
€ 33.675
€33
€ 33.675
€3.249
€3.283
€3.605
€1.030
€2.652
€0
€2.652
€166
€827
€101
€6.752
€6.752
€3.017
€3.735
€6.752
€6.752
€6752
€293
€1.521
€293
€1.521
€0
€467
€2.438
€2.154
€11.245
€570
€2.974
€0
€11.571
€42
€230
€0
€2.845
€3.233
€31.303
€120
€10
€110
€0
€23.143
€438
€20.000
€358
€43.143
€0
€138.000
€690
€0
€0
€690
€0
€690
€796
€0
€0
€0
€796
€0
€796
€-106
€690
€796
€-106
€607
€0
€ 58.311
€1.521
€31.303
€120
€10
€110
€-106
€32.828
€607
€32.221
€293
€1.521
€467
€2.438
€2.154
€11.245
€570
€2.974
€0
€11.571
€42
€230
€0
€2.845
€3.233
€31.303
€10
€120
€690
€-796
€-106
€138.000
€690
€23.143
€438
€20.000
€358
€43.143
€796
€607
€607
€198
€274
€309
€420
€1.201
€1.201
€36.012
€594
€607
€198
€274
€309
€420
€34.141
€34.141
€34.141
€50.000
€50.000
€623
€2.385
€2
€2.141
€25.300
€3.690
€34.141
€1.521
€31.303
€110
€32.934
€-106
€32.828
€607
€607
€32.221
€32.221
€32.221
€3.044
€32.221
€3.141
€6.185
€1.124
€40
€1.703
€2.867
€3.318
€3.526
€3.526
€-208
€208
€110
€110
€58.311
€1.521
€31.303
€32.824
€25.487
€110
€6
€4.843
€2.891
€7.734
€4.031
€0
€4.031
€3.703
€3.703
€519
€3.184
€0
€23.143
€438
€20.000
€358
€43.143
€0
€138.000
€690
€0
€0
€690
€0
€690
€796
€0
€0
€0
€796
€0
€796
€-106
€0
€0
€0
€32.221
€0
€ 58.311
€0
€0
€0
€0
€3.184
€3.184
€3.184
€12.116
€4.843
€2.891
€7.734
€4.031
€4.031
€3.703
€3.703
€519
€3.184
€2.891
€34.141
€34.141
€34.141
€50.000
€50.000
€623
€2.385
€2
€2.141
€25.300
€3.690
€34.141
€3.184
€3.184
€15.300
€3.184
€2.837
€170
€-3.007
€2.860
€-2.860
€2.860
€2.837
€ 170
€23
€2.860
€0
€2.860
€3.184
€3.184
€58.311
€58.311
€3.184
€183
€-2.860
€183
€-2.677
€2.677
€0
€0
€4.843
€4.031
€4.843
€4.031
€4.843
€4.031
€4.843
€4.031
€4.843
€4.031
€11.920
€11.920
€1.375
€950
€5.892
€8.217
€3.703
€4.843
€4.031
€4.843
€4.031
€4.843
€4.031
€4.843
€4.031
€4.843
€4.031
€11.920
€15.383
€11.920
€15.383
€0
€811
€811
€1.375
€1.156
€1.375
€1.156
€950
€917
€5.892
€11.600
€6.842
€12.517
€11.920
€15.383
€8.217
€14.484
€3.703
€899
€9.818
€1.594
€6.204
€2.020
€ 2.020
€601
€3.138
€0
€11.245
€2.395
€12.519
€2.695
€14.074
€513
€2.679
€6.204
€43.655
€100.000
€1.659
€100.000
€0
€352.000
€1.760
€0
€0
€1.760
€0
€1.760
€1.659
€0
€0
€0
€1.659
€0
€1.659
€101
€35
€33
€2
€2
€2
€278.955
€0
€0
€0
€0
€0
€0
€0
€0
€0
€0
€278.955
€278.955
€0
€278.955
€50.000
€50.000
€178.955
€12.042
€12.042
€8.068
€2
€12.042
€3.974
€226
€228
€37
€100.000
€1.659
€12.845
€3.303
€20.212
€100.077
€4.451
€0
€17.812
€0
€9.886
€10.662
€0
€99.647
€60
€278.955
€499
€125
€73
€697
€ 66.055
€660
€37
€376
€48
€50
€25
€499
€3
€10
€10
€50
€73
€37
€43.655
€-37
€43.618
€228
€228
€43.883
€37
€43.846
€15.952
€99
€-89
€6.210
€22.172
€91
€43.655
€2
€-2
€43.655
€37
€43.618
€601
€3.138
€0
€11.245
€2.395
€12.519
€2.695
€14.074
€513
€2.679
€6.204
€43.655
€1.760
€-1.659
€101
€99
€2
€35
€33
€91
€89
€2
€352.000
€1.760
€100.000
€1.659
€1.760
€1.659
€101
€91
€89
€2
€37
€37
€499
€125
€73
€697
€ 66.055
€660
€37
€376
€48
€50
€25
€499
€3
€10
€10
€50
€73
€278.955
€278.955
€278.955
€50.000
€50.000
€178.955
€166.913
€12.042
€12.042
€8.068
€2
€12.042
€3.974
€226
€228
€12.845
€3.303
€20.212
€100.077
€4.451
€0
€17.812
€0
€9.886
€10.662
€0
€99.647
€60
€278.955
€43.655
€43.655
€2
€-2
€43.655
€37
€37
€43.618
€228
€43.846
€35.941
€3.396
€7.677
€2.848
€35.941
€3.504
€9.748
€228
€70
€9.818
€772
€822
€1.594
€8.224
€6.204
€6.204
€2.020
€4.989
€3.172
€903
€914
€ 914
€0
€11.245
€903
€4.707
€903
€15.952
€100.000
€1.659
€100.000
€0
€352.000
€1.760
€0
€0
€1.760
€0
€1.760
€1.659
€0
€0
€0
€1.659
€0
€1.659
€101
€1.725
€1.626
€99
€99
€89
€278.955
€0
€0
€0
€0
€0
€0
€0
€0
€0
€0
€278.955
€278.955
€0
€278.955
€50.000
€50.000
€178.955
€166.913
€50.000
€33.500
€10
€50.000
€16.500
€938
€116.913
€24.552
€7
€116.913
€92.361
€5.255
€6.210
€100.000
€1.659
€12.845
€3.303
€20.212
€100.077
€4.451
€0
€17.812
€0
€9.886
€10.662
€0
€99.647
€60
€278.955
€15.962
€6.210
€22.172
€22.172
€43.655
€2
€-2
€228
€43.883
€91
€15.952
€99
€-89
€15.962
€0
€11.245
€903
€4.707
€903
€15.952
€1.760
€-1.659
€101
€2
€99
€1.725
€1.626
€91
€2
€89
€352.000
€1.760
€100.000
€1.659
€1.760
€1.659
€101
€91
€2
€89
€499
€125
€73
€697
€ 66.055
€660
€37
€37
€376
€48
€50
€25
€499
€3
€10
€10
€50
€73
€278.955
€278.955
€278.955
€50.000
€50.000
€178.955
€12.042
€166.913
€50.000
€33.500
€10
€50.000
€16.500
€938
€116.913
€24.552
€7
€116.913
€92.361
€5.255
€6.210
€12.845
€3.303
€20.212
€100.077
€4.451
€0
€17.812
€0
€9.886
€10.662
€0
€99.647
€60
€278.955
€15.952
€15.952
€99
€-89
€15.962
€6.210
€22.172
€15.962
€1.508
€15.962
€1.556
€3.064
€6.210
€1.925
€4.989
€1.469
€1.703
€3.172
€1.817
€903
€903
€914

The accepted answer will not match $250.00 because it only accepts 1-2 digits for the first group of digits. It also fails for $0.99.

/^\$(?:[1-9]\d{0,2}(?:,\d{3})*|0)(?:\.\d{2})$/

本文标签: javascriptRegex format for dollar and commaStack Overflow