I have regular expresion validator with expression like:

```
^\d{1,4}(\,\d{1,3})?$
```

I wan`t to validate next formats:

Decimal numbers with max 3 decimal places like 0,125 1,15, 0,5 but not(1,1234) that is ok but, user can write 5 digits like (12345, 54321 ... )

Exclude 0, so if user just write 0, there will be an error but user can write 0,5 or 0,125...

**I don`t know how to manage that**

So everything is working fine except scenario 2. I don`t know how to exclude only 0... can I do that with regular expression validator, or should I try with custom validator in function(check if value is 0)

You could prohibit the number from containing all zeros with a *negative lookbehind*. That would also invalidate all entries that consist of zeros and dots, but that's probably a good thing: it is very likely that since you do not want a standalone zero, you do not want `00`

, `000`

, or `0.000`

as well:

```
^(\d{1,4}(\.\d{1,3})?)(?<!^[0\.]+)$
// ^^^^^^^^^^^^
// |||
// The lookbehind part
```

The part that I added to your expression checks that the string does not consist entirely of zeros and dots. Here is a demo on ideone.

Similar Questions

I'm looking for a regular expression to match a Dutch phone number. These are the formatting requirements: Should start with 0 Contains maximum of 1 (optional) dash - character, for now it does no

I'm trying to set up a Google Analytics goal url regular expression to match: Any number of any characters followed by first-login? followed by any number of any characters. Examples: /user/452/fi

My definition of Custom Decimal => The number can be represented as (p,s) where p is the precision and s is the scale and then describe everything with respect to precision and scale. Use Custom De

I need a regular expression to find a number in the range [40010-40100]. I tried with this 40[0-1][0-9][0-9] but it doesn't work. Could someone help me?

I've been building this regular expression for a while and so far I've had not much luck. Anyways the regular expression is supposed to catch the following characters: {}[]+-*/,.(); The boolean expres

Please help me make regular expression for positive decimal number with 0, 1 or 2 decimal places. It must allow comma and dot. For example it must allow: 0,01 0.01 0,1 1 1.1 1,11 but not allow: -1 0.

I need a regular expression to match phone numbers. I just want to know if the number is probably a phone number and it could be any phone format, US or international. So I developed a strategy to det

I need a regular expression that satisfy these rules: The maximum number of decimal point is 3 but a number with no decimal point (e.g 12) should be accepted too the value must be at least 0 the valu

I can't seem to get a simple regular expression to work. Here's what I have at the moment: $(.Hours).on('input', function (e) { var regex = /^\d+(\.\d{0,2})?$/g; if (!regex.test(this.value)) { if (!

Currently I have the following regular expression that matches 8 digits alphanumeric, I want to modify it such that it has to start with the number 2 and contains at least 2 numbers in this 8 digit. H

I am new to regular expression. I need to validate the following using regular expression: an input string is digit only between 6 and 10 characters long

I want to match 1234 5678 or 12345678 Is this regular expression wrong? if(!number.matches(^\\d{4}[, ]\\d{4}$)){ throw new Exception( number is not valid : +number); }

I want an regular expression in for international Phone Number which includes the follwing things : 20 characters, 0-9 digit,- (Hyphen), (space),(,) (brackets) I am using asp.net 4.0 and mvc 3

I am trying to write a regular expression that will only match with qtr1, qtr2, qtr3, qtr4 with help of following regex [q|qtr|qtrs|quarter]+[1-4] but the problem is if i ask something like this Fico

My aim is to write a regular expression for a decimal number where a valid number is one of xx.0, xx.125, xx.25, xx.375, xx.5, xx.625, xx.75, xx.875 (i.e. measured in 1/8ths) The xx can be 0, 1 or 2 d

Basically, the input field is just a string. People input their phone number in various formats. I need a regular expression to find and convert those numbers into links. Input examples: (201) 555-121

How to write regular expression for following conditions: Should have only numbers Must be 8 digits long Must start with 8 or 9 or 6 So for I can do only for first two conditions. I am not sure how

I'm looking for a regular expression to match the beginning of specific words throughout a string. Say I have this: This is the example string of text. I would be looking to match each T that starts

Possible Duplicate: Is there a regular expression to detect a valid regular expression? Regular expression for finding a regular expression? I have an application that enables the user to input a re

First I am using python 2.7 I have these possibilities of the string: 3 paths 12 paths 12 path rooms Question what is the reqular expression to get the number without the text. thanks

I have to write a .NET Regular Expression which validates if a string is alpha-numeric and has 4 or 8 characters (nothing less, nothing more). How can I do that? I tried with ([a-zA-Z0-9]{4})|([a-zA-Z

Hi I need regex for phone number validation for the below format +1-646-222-3333 I have written expression like ^(+)([0-9]{3}-[0-9]{3}-[0-9]{4}) But its not working. Can I know where I did wrong?

I'm trying to figure out the regular expression that will match any character that is not a letter or a number. So characters such as (,,@,£,() etc ... Once found I want to replace it with a blank spa

I wanted to write a specific regex to do the following in a specific file format. It should be able to check with a regular expression whether the third field is just an O or has anything following th

I am trying to figure out a regular expression for an asp.net RequiredFieldValidator that validates decimal values from 1.001 to 99.9999. This means every value greater than or equal to 1.001 and less

I want to have a validation in php for price which can be 100 or 100.45 The 2 decimal places will be optional. Now the validation should allow only digits. So far i managed to achieve it if (!preg_mat

Below is the format in which the number should be: 123456789 $XXXX$$$X The number must be 9 characters in length. None of the $ positions can be a zero. Can some one help?

I would like to remove spaces(' '), dots('.') and hyphens(-) from a string, using a regular expression. My current approach: string input = hello how --r dsbadb...dasjidhdsa.dasbhdgsa--dasb; var res

Perl regular expression to remove white spaces in a line and extract specific columns my line looks like this: 324446 psharma jobA 2 0 435529 0 0 0 435531 Here I can split the line with split functio

I need to verify if the answer entered by a user is correct for an online quiz. The answer is supposed to be a decimal number that may be entered in a number of different ways. For example, 0.666666

I would like to get parts of a string separated by the type (number or character) Simplified initial situation: var content = 'foo123bar456'; Desired result: result = ['foo', 123, 'bar', 456]; This

I would like to know how to write a regular expression for validation of numeric field with less than 13 digits. No decimal.

Looking for some help with a Regular Expression to do the following: Must be Alpha Char Must be at least 1 Char Must NOT be a specific value, e.g. != Default Thanks for any help, Dave

Please help me to make a Regular Expression with following rule - Max number can be 9999.99 Should be non-negative Can not be 0, but 0.01 and so on is valid So, I need a non negative number between

I have to specify a pair of ports using format number1-number2. Number1 and number2 both in range [0-65535]. But number2 is always larger than number1. Is it possible to make a regular expression to

Given a regular expression in C#, is there a way to generate a word that is accepted by this regular expression? For instance, let's consider: [ab]c*b* Is there a function that can automatically gen

^(0)?[0-9]{0,}((\.){1}[0-9]{0,2}){0,1}$ The above regular expression allows me to enter numbers upto 4 decimal places with an optional 0 before the decimal(.) point. But it is not throwing error when

I have a regular expression that cleans up phone numbers and turns them into valid phones numbers as such: +1 123-1223. Regular Expression: Regex.Replace(phone, @^\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\

How can i write valid regular expression for Oracle's Number(2,2), Also digits after decimal should be either, 1 or 2 but not more than 2,also it can be optional. The numer should never start with [1-

I have to generate a regular expression to the check the first letter of any word for 'A','D'and 'E'.Word can be of any length.What should be the regular expression for this.

What is the regular expression for . and .. ? if(key.matches(.)) { do something } The matches accepts String which asks for regular expression. Now i need to remove all DOT's inside my MAP.

I need to write a regex expression to check if a serial number matches the following format: XX-XXXXX-XXXXXX Example: 50-99627-036043 A brief description of conditions: must be exactly 15 char long m

I want a regular expression for a number which is a continuous string of digits with no spaces - Please help ! Thankyou

I created a regular expression for the format XX-XX-XX-XX-XX, where XX is a alphanumeric. Regular expression is ^[a-z0-9A-Z]{2}-[a-z0-9A-Z]{2}-[a-z0-9A-Z]{2}-[a-z0-9A-Z]{2}$. But what I really want to

I am new to javascript and recently I wanted to use regular expression in order to get a number from url and store it into a var as string and another var as digit. For example I want to get the numbe

I'm new with regular expression uses, and for 2 days I'm searching how to pull a specific data from a string, but without success. This string is a partial from a longer string, I need to find a param

music_neu_3, music_pos_76, books_neg_104 How could I use regular expression in Python to find such pattern that word + underline + word + underline + number?

What is a regular expression for strings of 0 and 1 with an even number of zeros and an even number of ones? I have something like (1*01*01*)*(0*10*10*)*. Does it look good?

I apologize if this post is repetitive but I've searched extensively and can't seem to find a solution that works. I am working on a regular expression for C#. Here are the criteria to match: Currenc

can some tell how can i write regular expression matching abc.com.ae or abc.net.af or anything ,ae which is the last in the string is optional this is successfull with / but not . don't know why ^[a-