Regular judgment the horizontal line (-) either side of the input is a positive integer and a positive floating point number, or just enter a full or floating point number

Source: Internet
Author: User

background :
The actual project will use the interval price, so there is the "lowest price-high price" or "price" of the two formats, determine the character input format the first must think of a regular expression, but not used for a long time, and common on the Internet: such as mailbox, mobile phone number, URL, IP, etc., but this I did not search, So I only wrote it myself. references :Regular expression table: Http://www.jb51.net/shouce/jquery1.82/regexp.html Test Regular expression: http://regex.supfree.net/ Dry Area:^\d{1}$|^\d+ (\.\d+)? [-]? (\d+\.)? \d+$|(^\d\.\d$)Or explain the mistakes can be modified using: A, ^\d{1}$|: This judge only a number of cases 0-9b, (^\d\.\d$): Judge 9.1 Three length of the case C, ^\d+ (\.\d+)? [-]? (\d+\.)? \d+$|: Judging all the other cases AB is a case of adding a bad judgment in C remaining questions:There is the middle line (-) must be greater than the previous situation has not been considered, the above may be too complex, I hope the great God to help add a better way, thank you!

Regular judgment the horizontal line (-) either side of the input is a positive integer and a positive floating point number, or just enter a full or floating point number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.