Regex need to match decimal(14,2) - regex

I have been trying with a regex ^\d{0,12}(\.{0,1}\d{0,2})$.
Valid matches:
.22
0.22
123456789012.01
123.2
123.
125
120.00
125444
123456789123.
Invalid match
1234567891232
12345678912345
How to restrict invalid matches as this regex is working fine for all other cases
now i have to restrict the digits before decimal to just 12, i hope now u all will get what i need.

I think you want something like this,
^(?:\d{0,12}\.\d{0,2}|\d{0,12})$
DEMO

Related

Regex for "everything except 34,37" WITHOUT negative lookahead

Every time this is asked, the answer is to use negative lookahead like so: (?!x)
Well unfortunately I must implement an American Express check in vb6, which does NOT support negative lookaheads or negative look behinds.
Is it possible to match everything except 34, 37 using the oldest imaginable implementation of regular expressions?
I expected this sort of thing to work:
^[1,2,4-9][1-3,5-6,8-9][0-9]{13}$
I've been able to match AmEx with this expression of course: ^3[47][0-9]{13}$ but I haven't found a way to inverse the validation rule.
Here is my validator setup:
<asp:RegularExpressionValidator
ID="AmExValidator"
Display="None"
ControlToValidate="txtCreditCardNumber"
ValidationExpression="^[1,2,4-9][1-3,5-6,8-9][0-9]{13}$"
ErrorMessage="American Express cards are not accepted."
ValidationGroup="Payment"
runat="server">
</asp:RegularExpressionValidator>```
You can use
^([0-24-9][0-9]|3[0-35689])[0-9]{13}$
See the regex demo. Details:
^ - start of string
([0-24-9][0-9]|3[0-35689]) - 00 to 29 and 40 to 99, or 3 followed with a digit other than 4 and 7
[0-9]{13} - thirteen digits
$ - end of string.

Regular Expression pattern does not match my requirements

I need a regular expression to check that an input can contain only digits,but cannot be 0, the number should be a digit between 1 and 12 digits.
So far I have tried that:
data-ng-patern="/^[1-9]{1,12}$/"
However doing that I don't allow 0 in any case so for example the input 120, would not match my pattern.
How can I accomplish that?
Thank you very much.
You must use /^[1-9][0-9]{0,11}$/
Please have a look at the working demo.
Input:
0
123
120
023
Matches:
123
120

How to match a one of a set of numbers?

I am trying to match a group of numbers in regex that consist of one of the following:
1,2,3,4,5,6,7,8,9,10,11
But I am having trouble figuring out the regex.
For single digits this pattern worked fine "0|1|2|3|4|5|6|7|8|9" but it fails on double digit numbers. For example 12 passes as ok due to the regex finding the 1 in 12.
You can use begin and end anchors to force the whole string to be matched:
^(0|1|2|3|4|5|6|7|8|9|10|11)$
Which can be shortened to:
^(\d|10|11)$
This will work if you want to check if just one number is between 0 and 11.
^[0-9]$|^1?[0-1]$
If you want to match a string like:
1,2,3,12,32,5,1,6,8, 11
and match 0-11 then you can use the following:
(?<=,|^)([0-9]|1?[0-1])(?=,|$)
use this regex ^(0|1|2|3|4|5|6|7|8|9|(10)|(11))$

perl regular expression digit match

Doing the below regex match to verify whether date is in the YYYY_MM_DD Format. But the regular expression gives an error message if i have a value of 2012_07_7. Date part and month should be exactly 2 digits according to the regex pattern. Not sure why it's not working.
if ($cmdParams{RunId} !~ m/^\d{4}_\d{2}_\d{2}$/)
{
print "Not a valid date in the format YYYY_MM_DD";
}
Your regex specifies exactly 2 digits for the day component, if you want to allow either 1 or 2 digits you should use {1,2} rather than {2}
Well if you look at your data that you have: 2012_07_7 you can see that the day-part is not of two digits.
Obviously. Your pattern dictates that the last numeric chunk should be of two digits, whereas you are providing 1. So if you want your pattern to match this text, try something like:
if ($cmdParams{RunId} !~ m/^\d{4}_\d{2}_\d\d?$/)
My solution: ^\d{4}_(?:1[0-2]|0?[1-9])_(?:3[01]|[1-2]\d|0?[1-9])$
this pattern match: 2000_12_01 or 2001_1_1 or 2001_02_1

ReGex Phone No Format in Philippines

I'm trying to match exactly the following format:
+639201112222
09201112222
and this is all Ive tried so far:
(\+63|0)?\d{10}
the problem is that it match 2920111222 in 29201112222. How can i create a pattern that will match only the formats below?
+63XXXXXXXXXX
0XXXXXXXXXX
+63 or 0 plus 10 digit number only
where X are all digits from 0-9.
Thank you.
You want to do:
((\+63)|0)\d{10}
A regex for various phone number combinations (just quickly used rubular.com for this):
/(^0|[89]\d{2}-\d{3}\-?\d{4}$)|(^0|[89]\d{2}\d{3}\d{4}$)|(^63[89]\d{2}-\d{3}-\d{4}$)|(^63[89]\d{2}\d{3}\d{4}$)|(^[+]63[89]\d{2}\d{3}\d{4}$)|(^[+]63[89]\d{2}-\d{3}-\d{4}$)/
Validates:
0917-411-1111
0917-4111111
917-411-1111
9174111111
+63917-411-1111
63917-894-3454
639172342345
+639174111111
Here's a solution:
http://jsfiddle.net/kZMRx/