XhCode Online Converter Tools

Tester a generátor regex

Tester a generátor Regex vám pomôže otestovať váš regulárny výraz a vygenerovať kód ReGEX pre JavaScript PHP Go Java Ruby a Python.

Common Regular Expressions

Check digit expressions

  • Digit:
    ^[0-9]*$
  • N digits:
    ^\d{n}$
  • At least N digits:
    ^\d{n,}$
  • m-n digits:
    ^\d{m,n}$
  • Zero and non-zero start digits:
    ^(0|[1-9][0-9]*)$
  • Nonzero number with up to two decimal places:
    ^([1-9][0-9]*)+(.[0-9]{1,2})?$
  • A positive or negative number with one or two decimal places:
    ^(\-)?\d+(\.\d{1,2})?$
  • Positive, negative, and decimals:
    ^(\-|\+)?\d+(\.\d+)?$
  • A positive real number with two decimal places:
    ^[0-9]+(.[0-9]{2})?$
  • A positive real number with 1 to 3 decimal places:
    ^[0-9]+(.[0-9]{1,3})?$
  • A non-zero positive integer:
    ^[1-9]\d*$  or  ^([1-9][0-9]*){1,3}$  or  ^\+?[1-9][0-9]*$
  • A non-zero negative integer:
    ^\-[1-9][]0-9"*$  or  ^-[1-9]\d*$
  • Non-negative integers:
    ^\d+$  or  ^[1-9]\d*|0$
  • Non-positive integer:
    ^-[1-9]\d*|0$  or  ^((-\d+)|(0+))$
  • Non-negative floating-point numbers:
    ^\d+(\.\d+)?$  or  ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$
  • Non-positive floating-point number:
    ^((-\d+(\.\d+)?)|(0+(\.0+)?))$  or  ^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$
  • Floating point number:
    ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$  or  ^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$
  • Negative Float:
    ^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$  or  ^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$
  • Floating point number:
    ^(-?\d+)(\.\d+)?$  or  ^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$

Check character expressions

  • Alpha-Numeric Characters:
    ^[A-Za-z0-9]+$  or  ^[A-Za-z0-9]{4,40}$
  • All characters with a length of 3-20:
    ^.{3,20}$
  • A string of 26 letters:
    ^[A-Za-z]+$
  • A string of 26 uppercase English letters:
    ^[A-Z]+$
  • A string of 26 lowercase alphabetic characters:
    ^[a-z]+$
  • A string of numbers and 26 letters:
    ^[A-Za-z0-9]+$
  • A string of numbers, 26 letters, or an underscore:
    ^\w+$  or  ^\w{3,20}$
  • input with ^%&',;=?$\":
    [^%&',;=?$\x22]+
  • It is forbidden to input characters with ~:
    [^~\x22]+

Special Needs Expressions

  • Email:
    ^[a-zA-Z0-9_.+-][email protected][a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$
  • URL or Domain name:
    ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
  • Date (MM/DD/YYYY)/(MM-DD-YYYY)/(MM.DD.YYYY)/(MM DD YYYY):
    ^(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2}$
  • 12 months of the year(01~09 1~12):
    ^(0?[1-9]|1[0-2])$
  • 31 days a month(01~09 1~31):
    ^(0[1-9]|[12][0-9]|3[01])$
  • Password:
    ^.*(?=.{6,})(?=.*d)(?=.*[A-Z])(?=.*[a-z])(?=.*[[email protected]#$%^&*? ]).*$
  • US Phone Numbers
    \b\d{3}[-.]?\d{3}[-.]?\d{4}\b
  • US Zip code
    ^[0-9]{5}(?:-[0-9]{4})?$
  • Slug
    ^[a-z0-9-]+$
  • All the special characters need to be escaped
    /[\-\[\]\/\\\{\}\(\)\*\+\?\.\^\$\|]/
  • xml file:
    ^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$
  • Regular expressions for Chinese characters:
    [\u4e00-\u9fa5]
  • Double-byte characters:
    [^\x00-\xff] 
  • Blank line:
    \n\s*\r    (be used to delete blank lines)
  • HTML tags:
    <(\S*?)[^>]*>.*?|<.*? />
  • The leading and trailing whitespace character:
    ^\s*|\s*$ or (^\s*)|(\s*$)
  • IP address:
    ((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))