Android Code Snippet Find Numbers RegEx Expressions

icakinser

Member
Licensed User
Here is a list of expressions to use with RegEx:
Positive Integers:

^\d+$
Negative Integers:

^-\d+$
Integer:

^-?\d+$
Positive Number:

^\d*\.?\d+$
Negative Number:

^-\d*\.?\d+$
Positive Number or Negative Number:

^-?\d*\.{0,1}\d+$
Phone number:

^\+?[\d\s]{3,}$
Phone with code:

^\+?[\d\s]+\(?[\d\s]{10,}$
Year 1900-2099:

^(19|20)[\d]{2,2}$
Date (dd mm yyyy, d/m/yyyy, etc.):

^([1-9]|0[1-9]|[12][0-9]|3[01])\D([1-9]|0[1-9]|1[012])\D(19[0-9][0-9]|20[0-9][0-9])$
IP v4:

^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]){3}$
 
Top