Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

/
/
gm

Test String

Code Generator

Generated Code

$re = '/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):\d*/m'; $str = '10.0.1.101:80 open 10.0.1.52:22 open 10.0.1.190:80 open 10.0.1.241:80 open 10.0.1.103:22 open 10.0.1.242:135 open 10.0.1.241:135 open 10.0.1.110:22 open 10.0.1.1:22 open 10.0.1.218:80 open 10.0.1.221:135 open 10.0.1.197:22 open 10.0.1.212:80 open 10.0.1.214:22 open 10.0.1.211:80 open 10.0.1.101:445 open 10.0.1.52:80 open 10.0.1.241:445 open 10.0.1.86:80 open 10.0.1.241:1433 open 10.0.1.217:80 open 10.0.1.101:8000 open 10.0.1.86:1433 open 10.0.1.101:443 open 10.0.1.106:135 open 10.0.1.115:443 open 10.0.1.220:80 open 10.0.1.210:80 open 10.0.1.219:135 open 10.0.1.115:80 open 10.0.1.212:8000 open 10.0.1.191:21 open 10.0.1.115:445 open 10.0.1.102:22 open 10.0.1.52:3306 open 10.0.1.217:443 open 10.0.1.190:135 open 10.0.1.192:135 open 10.0.1.191:445 open 10.0.1.111:443 open 10.0.1.210:443 open 10.0.1.105:80 open 10.0.1.198:22 open 10.0.1.218:443 open 10.0.1.106:80 open 10.0.1.115:81 open 10.0.1.220:1433 open 10.0.1.190:445 open 10.0.1.105:22 open 10.0.1.216:443 open 10.0.1.106:445 open 10.0.1.191:135 open 10.0.1.197:80 open 10.0.1.197:443 open 10.0.1.241:8080 open 10.0.1.216:80 open 10.0.1.210:8000 open 10.0.1.215:80 open 10.0.1.212:443 open 10.0.1.219:443 open 10.0.1.242:80 open 10.0.1.111:80 open 10.0.1.197:82 open 10.0.1.115:8080 open 10.0.1.105:443 open 10.0.1.221:443 open 10.0.1.219:80 open 10.0.1.86:21 open 10.0.1.219:445 open 10.0.1.192:445 open 10.0.1.192:21 open 10.0.1.191:80 open 10.0.1.242:445 open 10.0.1.215:8000 open 10.0.1.215:443 open 10.0.1.101:135 open 10.0.1.115:135 open 10.0.1.198:443 open 10.0.1.86:135 open 10.0.1.115:82 open 10.0.1.115:8888 open 10.0.1.192:82 open 10.0.1.216:8000 open 10.0.1.211:443 open 10.0.1.115:8088 open 10.0.1.191:8090 open 10.0.1.115:10000 open 10.0.1.111:9000 open 10.0.1.219:8099 open 10.0.1.211:9087 open 10.0.1.217:9087 open 10.0.1.218:9087 open 10.0.1.211:2020 open 10.0.1.218:2020 open 10.0.1.217:2020 open 10.0.1.115:20000 open 10.0.1.241:8009 open 10.0.1.211:9084 open 10.0.1.217:9084 open 10.0.1.218:9084 open 10.0.1.101:3000 open 10.0.1.192:83 open 10.0.1.192:90 open 10.0.1.211:9443 open 10.0.1.217:9443 open 10.0.1.218:9443 open 10.0.1.115:7088 open 10.0.1.115:8082 open 10.0.1.115:8300 open 10.0.1.210:8300 open 10.0.1.212:8300 open 10.0.1.216:8300 open 10.0.1.215:8300 open 10.0.1.115:8081 open 10.0.1.192:84 open 10.0.1.211:88 open 10.0.1.217:88 open 10.0.1.218:88 open 10.0.1.211:8084 open 10.0.1.217:8084 open 10.0.1.218:8084 open 10.0.1.210:9080 open 10.0.1.212:9080 open 10.0.1.216:9080 open 10.0.1.215:9080 open [*] 10.0.1.115 (Windows Server 2008 R2 Standard 7601 Service Pack 1) [*] WebTitle:http://10.0.1.218:9443 400 None [*] WebTitle:http://10.0.1.191:8090 200 None [*] WebTitle:http://10.0.1.192:83 200 None [*] WebTitle:http://10.0.1.217:9084 404 Error 404 Not Found [*] WebTitle:http://10.0.1.219 200 None [*] WebTitle:http://10.0.1.115:7088 404 None [*] WebTitle:http://10.0.1.115:8082 404 None [*] WebTitle:http://10.0.1.218:9084 404 Error 404 Not Found [*] 10.0.1.242 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1) [*] WebTitle:http://10.0.1.211:9443 400 None [*] WebTitle:http://10.0.1.220 404 None [*] WebTitle:http://10.0.1.211:9084 404 Error 404 Not Found [*] WebTitle:http://10.0.1.115:8080 404 None [*] WebTitle:http://10.0.1.52 200 None [*] WebTitle:http://10.0.1.115:8088 400 None [*] WebTitle:https://10.0.1.198 200 None [*] WebTitle:http://10.0.1.217:9443 400 None [+] ftp://10.0.1.191:21:anonymous [->]10594_20110501035吴玮_2003.DOC [->]aspnet_client [->]cnki [->]FILES [->]weipu [->]超星 [*] WebTitle:http://10.0.1.115:8081 200 title [*] WebTitle:http://10.0.1.115 200 title [*] WebTitle:http://10.0.1.115:8888 405 None [*] WebTitle:https://10.0.1.101 404 None [*] WebTitle:https://10.0.1.115 403 None [*] WebTitle:https://10.0.1.212 200 None [*] WebTitle:http://10.0.1.105 200 None [*] WebTitle:https://10.0.1.211 200 " + ID_VC_Welcome + " [*] WebTitle:https://10.0.1.215 200 None [*] WebTitle:https://10.0.1.219 200 None [*] WebTitle:http://10.0.1.197 200 Drcomɏ͸µǂ¼´° [*] WebTitle:https://10.0.1.216 200 None [*] WebTitle:http://10.0.1.101:8000 200 用户主页 - 广西科技大学 - 全球最大的虚拟现实三维互动在线教育云平台 [*] WebTitle:http://10.0.1.190 200 广西科技大学学位论文管理系统 [*] WebTitle:https://10.0.1.217 200 " + ID_VC_Welcome + " [*] WebTitle:http://10.0.1.212 200 None [*] WebTitle:http://10.0.1.210 200 None [*] WebTitle:http://10.0.1.211 200 " + ID_VC_Welcome + " [*] WebTitle:https://10.0.1.210 200 None [*] WebTitle:http://10.0.1.217 200 " + ID_VC_Welcome + " [*] WebTitle:http://10.0.1.192:84 200 None [*] WebTitle:http://10.0.1.218 200 " + ID_VC_Welcome + " [*] WebTitle:https://10.0.1.218 200 " + ID_VC_Welcome + " [*] WebTitle:http://10.0.1.215 200 None [*] WebTitle:http://10.0.1.216 200 None [*] WebTitle:http://10.0.1.191 200 None [*] WebTitle:http://10.0.1.111:9000 200 平台登录 [*] WebTitle:http://10.0.1.115:82 311 None [*] WebTitle:http://10.0.1.192:90 200 None NetInfo: [*]10.0.1.241 [->]GYZCGL-SERVER1 [->]10.0.1.241 [->]171.168.2.7 [->]172.168.1.5 [->]2002:aba8:207::aba8:207 [->]2002:aca8:105::aca8:105 [+] InfoScan:http://10.0.1.52 Shiro [*] WebTitle:https://10.0.1.197 200 Drcomɏ͸µǂ¼´° [*] WebTitle:http://10.0.1.241:8080 404 None [*] WebTitle:http://10.0.1.242 200 None [*] WebTitle:http://10.0.1.241 403 403 - ½ûֹ·Îʺ ·Îʱ»¾ܾø¡£ [*] WebTitle:http://10.0.1.219:8099 200 None [*] WebTitle:http://10.0.1.101 200 Home [*] WebTitle:https://10.0.1.218:9443 200 None [*] WebTitle:http://10.0.1.86 403 403 - ½ûֹ·Îʺ ·Îʱ»¾ܾø¡£ [*] WebTitle:https://10.0.1.217:9443 200 None [*] WebTitle:https://10.0.1.105 200 None [*] WebTitle:https://10.0.1.211:9443 200 None [*] 10.0.1.241 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1) [*] WebTitle:http://10.0.1.192:82 200 None [*] WebTitle:http://10.0.1.106 200 柳州市节能科技产业孵化园 [*] WebTitle:https://10.0.1.221 200 None [*] WebTitle:http://10.0.1.115:81 400 None [+] https://10.0.1.211 poc-yaml-vmware-vcenter-unauthorized-rce-cve-2021-21972 [+] https://10.0.1.218 poc-yaml-vmware-vcenter-unauthorized-rce-cve-2021-21972 [+] https://10.0.1.217 poc-yaml-vmware-vcenter-unauthorized-rce-cve-2021-21972 '; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php