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

/
/
gmi

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 = "http:\\/\\/seluws1215\\/PM2\\/flex\\/ProcessManager(?:Flex)?\\.(?:php|html)\\?#?(?:v=\\d*&)?\\w*=(\\d*)"; final String string = "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=12932\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php \n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=13179\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=15032\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=15121\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=16452\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=13018\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=15568\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=15568\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=7056 \n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=16283\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=16283\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=16929\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=15587\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=16394\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=18585\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=17532\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=18292\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=18461\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=18848\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=18461\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=18461\n" + "http://seluws1215/pm2/flex/ProcessManagerFlex.php?start=20177\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20551 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20423 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=18613 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20870 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=17747 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=12930 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21032 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20551 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=17531 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21283 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=16929 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20804 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24585 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=23807 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21795 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24569 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24879 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24884 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24884 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20898 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24884 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24884 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25769 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24410 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24734 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25812 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21143 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24395 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25890 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25890 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25890 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25890 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25890 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=14869 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20777 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25819 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25819 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21735 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26842 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26842 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27084 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=23271 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27067 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25954 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=18409 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21659 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=18585 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21208 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28335 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24395 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24863 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27054 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26842 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26842 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=18585 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28340 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28948 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29035 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28927 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26352 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26361 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29021 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29189 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29189 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29719 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29626 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=296229 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29743 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27244 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29953 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21771 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28340 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21710 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27138 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27624 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28238 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=23275 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24410 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30508 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30508 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=18848 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30234 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30223 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30239 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30242 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30260 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24213 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24214 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27027 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=7056 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27069 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24410 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24410 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30622 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28658 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=25954 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=18543 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=12829 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24762 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26657 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29163 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31123 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20551 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31149 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31162 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29882 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=7057 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=17329 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29961 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=17049 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=17329 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31243 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31243 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30292 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27624 \n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20895\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20895\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=16385\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=14984\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31841\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=21735\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31840\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31847\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31864\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=14384\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=23271\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=24534\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27145\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=32265\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20728\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=6858\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28942\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26466\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28942\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28942\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30292\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=23298\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=32307\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=12930\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=30543\n" + "http://seluws1215/pm2/flex/ProcessManager.php?#page=16384\n" + "http://seluws1215/pm2/flex/ProcessManager.php?#page=17104\n" + "http://seluws1215/pm2/flex/ProcessManager.php?#page=16384\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=32306\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=28948\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=16384\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=32166\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26266\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=17016\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=7093\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=29866\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20551\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20728\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=20856\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=26228\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=32265\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=27145\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=13237\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=32711\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=32306\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=31342\n" + "http://seluws1215/pm2/flex/ProcessManager.php?start=33648"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); 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