regex:numbers:integers
Differences
This shows you the differences between two versions of the page.
regex:numbers:integers [2022/09/20 23:13] – created peter | regex:numbers:integers [2022/09/20 23:14] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Regex - Numbers - Integers ====== | ====== Regex - Numbers - Integers ====== | ||
+ | |||
+ | ===== Positive Integer ===== | ||
+ | |||
+ | < | ||
+ | ^\d+$ | ||
+ | </ | ||
+ | |||
+ | or | ||
+ | |||
+ | < | ||
+ | ^[1-9]\d*|0$ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Negative Integer ===== | ||
+ | |||
+ | < | ||
+ | ^-[1-9]\d*|0$ | ||
+ | </ | ||
+ | |||
+ | or | ||
+ | |||
+ | < | ||
+ | ^((-\d+)|(0+))$ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Positive Integer, excluding 0 ===== | ||
+ | |||
+ | < | ||
+ | ^[1-9]\d*$ | ||
+ | </ | ||
+ | |||
+ | or | ||
+ | |||
+ | < | ||
+ | ^([1-9][0-9]*){1, | ||
+ | </ | ||
+ | |||
+ | or | ||
+ | |||
+ | < | ||
+ | ^\+? | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Negative Integer, excluding 0 ===== | ||
+ | |||
+ | < | ||
+ | ^-[1-9]\d*$ | ||
+ | </ | ||
+ | |||
+ | or | ||
+ | |||
+ | < | ||
+ | ^\-[1-9][0-9]*$ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
regex/numbers/integers.1663715598.txt.gz · Last modified: 2022/09/20 23:13 by peter