This question already has answers here:
Decimal number regular expression, where digit after decimal is optional
(17 answers)
Closed 8 years ago.
I'm very new to regex. How do I match a decimalised number. I have found ones that include $ but just need to match any number which could include decimals.
e.g.
100
100.50
707.40
150.00
It's not very advanced, but:
/\d.*?\.\d.*/
Will match:
2.0
12.00
Won't match:
2
22
Doesn't check if it's a number though.
Related
This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 2 years ago.
What will be the regular expression to find a numerical string starting with a number other than 0 and having a length of 13 or more. This numerical string would be a substring inside a bigger alphanumeric string.
/[1-9][0-9]{12,}/
You're looking for a number from 1 to 9, then for 12 or more numbers from 0 to 9.
This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 2 years ago.
For example, I would like to find ty in:
erytypotym5ty
etytyty
koetymitywty
or il in:
keililmil
ilwrilltyil5ile
^.*(\w{2}).*\1.*\1.*$.
The two letters (also digits and _; you could replace \w with [a-zA-Z], if you don't want them) will be in group 1.
https://regex101.com/r/11Oq70/1
This question already has answers here:
What special characters must be escaped in regular expressions?
(13 answers)
How do I include negative decimal numbers in this regular expression?
(17 answers)
Closed 2 years ago.
Overall Goal: I would like to be able to capture a positive or negative number that looks something like this: xxx.xxx
I am also using Google Sheets, so I cannot use any lookarounds
Example Criteria:
+123.123 ---> 123.123
+30% ---> 30
+4% ---> 4
-1% ---> -1
0 ---> 0
+12 ---> 12
-3 ---> -3
What I've Tried:
The main regex I've been using is: -?\d+.?\d*. The problem with this one is that it also captures the percent signs, which I do not want. Percent signs seem to be considered part of the number.
I've also tried: -?\d+.?\d+. This one runs to the problem of not capturing single digit numbers.
. matches any character (Google uses RE2). You should escape it.
-?\d+\.?\d*
This question already has answers here:
Using regular expressions to validate a numeric range
(11 answers)
Closed 3 years ago.
How to put a number greater than 9 to regexp character set?
For example, I can do ^[01236]$, but what if I want to put 100 as an option to the set?
How do I solve this problem?
'\d+' can find number having 1 or more digits
If a number is greater than 9, it is more than 2 digits and the first digit is not 0. So the regex you might want to use is: ^[1-9][0-9]+$
If you want to put a specific multi character strings you can use:
^(10|100|200|301|601)$
Which will match 10, 100, 200, 301, and 601
test: https://regex101.com/r/bptbsx/1
This question already has answers here:
Regex for Australian phone number validation
(5 answers)
Closed 4 years ago.
The below expression is being used to accept Australian phone numbers.
I need to change the expression as to strictly accept total 10 digits (without spaces) if the number starts with 02/03/04/07/08.
^\({0,1}((0|\+61)\s?(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$
It does accept 10 digits if the number is entered like 03 11 11 1 111, but without spaces 8 digit number is accepted too.
You can use the use the following regex with alternation:
^ *(?:0 *[23478](?: *\d){8}|[1-9](?: *\d)*|0 *[01569](?: *\d)*) *$
Demo: https://regex101.com/r/bet7m1/1