Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Code Generator

Generated Code

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "(?(?=The following software are installed on the remote host :\\s+))(?<software>[^\\[]+)\\[version\\s(?<version>[^\\]]+)\\]"; final String string = "\"20811\",\"\",\"\",\"None\",\"182.56.44.12\",\"tcp\",\"445\",\"Microsoft Windows Installed Software Enumeration (credentialed check)\",\"It is possible to enumerate installed software.\",\"This plugin lists software potentially installed on the remote host by\n" + " crawling the registry entries in :\n" + " \n" + " HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\n" + " HKLM\\SOFTWARE\\Microsoft\\Updates\n" + " \n" + " Note that these entries do not necessarily mean the applications are\n" + " actually installed on the remote host - they may have been left behind\n" + " by uninstallers, or the associated files may have been manually\n" + " removed.\",\"Remove any applications that are not compliant with your organization's\n" + " acceptable use and security policies.\",\"\",\"\n" + " The following software are installed on the remote host :\n" + " \n" + " 7-Zip 15.12 (x64) [version 15.12]\n" + " Rapid Recovery Agent [version 6.1.3.100]\n" + " JXplorer [version 3.3.1]\n" + " System Center Endpoint Protection [version 4.10.207.0] [installed on 2016/10/26]\n" + " Notepad++ [version 6.8.8]\n" + " WinPcap 4.1.3 [version 4.1.0.2980]\n" + " Wireshark 2.2.4 (64-bit) [version 2.2.4]\n" + " Windows Firewall Configuration Provider [version 1.2.3412.0] [installed on 2015/11/20]\n" + " Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005 [version 12.0.21005] [installed on 2015/11/20]\n" + " Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219 [version 10.0.40219] [installed on 2015/12/17]\n" + " Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.40649 [version 12.0.40649] [installed on 2017/01/26]\n" + " Java 7 Update 79 (64-bit) [version 7.0.790] [installed on 2015/12/14]\n" + " Configuration Manager Client [version 5.00.8239.1000] [installed on 2018/03/28]\n" + " Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.40649 [version 12.0.40649.5]\n" + " Microsoft Endpoint Protection Management Components [version 4.10.0207.0] [installed on 2016/10/26]\n" + " Java SE Development Kit 7 Update 79 (64-bit) [version 1.7.0.790] [installed on 2015/12/14]\n" + " Microsoft Visual C++ 2005 Redistributable [version 8.0.61001] [installed on 2015/12/17]\n" + " Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.21005 [version 12.0.21005.1]\n" + " AppRecovery Agent [version 6.1.3.100] [installed on 2018/03/18]\n" + " Microsoft Silverlight [version 5.1.30514.0] [installed on 2015/11/20]\n" + " Microsoft Policy Platform [version 1.2.3602.0] [installed on 2015/11/20]\n" + " Microsoft Forefront Endpoint Protection 2010 Server Management [version 4.10.0207.0] [installed on 2016/10/26]\n" + " Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.40649 [version 12.0.40649] [installed on 2017/01/26]\n" + " Microsoft Security Client [version 4.10.0207.0] [installed on 2016/10/26]\n" + " Microsoft SQL Server System CLR Types (x64) [version 10.51.2500.0] [installed on 2015/12/17]\n" + " Microsoft SQL Server 2008 R2 Management Objects (x64) [version 10.51.2500.0] [installed on 2015/12/17]\n" + " Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219 [version 10.0.40219] [installed on 2015/12/17]\n" + " Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005 [version 12.0.21005] [installed on 2015/11/20]\n" + " Microsoft Visual C++ 2005 Redistributable (x64) [version 8.0.61000] [installed on 2015/11/20]\n" + " Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.21005 [version 12.0.21005.1]\n" + " \""; final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html