Numerical string withing another string [duplicate] - regex

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.

Related

RegEx for matching a number greater than 9? [duplicate]

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

How to find a part of string with regex? [duplicate]

This question already has answers here:
A regex to match a substring that isn't followed by a certain other substring
(5 answers)
Closed 3 years ago.
How to mark xy if the next symbol is not y?
I have four strings:
1. zxyy
2. zxyz
3. zxy
4. xy
The epxression should mark strings 2-4.
This regex marks the 2-nd string only:
([x][y])(?=[^y])
Thanx.
The regex recommended by Aaron works as I wished:
xy(?!y)
It marks 2. zxyz 3. zxy 4. xy, but not 1. zxyy.

Phone number regex should strictly allow 10 characters if starting with 02/03/04/07/08 [duplicate]

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

regex - decimalised number [duplicate]

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.

Regex - Select number between two characters [duplicate]

This question already has answers here:
Extract a single (unsigned) integer from a string
(23 answers)
Closed 3 years ago.
I can't figure out how to find a digit in a string like the following: Picture15.jpg. Does anyone have a RegEx of how to extract this digit in PHP?
Try
preg_match("/(\d+)/", "Picture15.jpg", $m);
echo $m[1];