SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Regex help

Threaded View

  1. #1
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Dallas, TX
    0 Post(s)
    0 Thread(s)

    Regex help

    I'm making a regex to validate money data, and these are the rules I want: (X will represent numbers)

    $ must be at front
    .XX -OR- .X is optional for end
    . at end NOT valid
    1-3 digits left of decimal
    infite combinations of XXX, where needed

    Examples of valid formats

    Examples of invalid formats:

    Here is what I've got so far, but I know it doesn't work...
    moneyReg = "^\\$([0-9]{1,3}[,]{1})*([0-9]{1-3})+(\\.[0-9]{1,2})?$";
    I've had several iterations that have had some success, but not total. This is where I am now, and it breaks pretty much on brain is too tired to backtrack.

    Thanks in advance!
    Last edited by beetle; Jul 23, 2002 at 10:12.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts