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
No Match

r"
"
gm

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 = "91.101.203.129.generic-hostname.arrownet.dk\\StainedFilthyBareAvians.txt |"; final String string = "##91.101.203.129.generic-hostname.arrownet.dk\\StainedFilthyBareAvians.txt\n" + "## using this guide: https://asicseer.com/page/kb#writing-config\n\n" + "global poolname1 sha.eobot.com:3333\n" + "global username1 eobot.1930455\n" + "global poolpass1 x\n" + "global sendworker1 yes\n" + "global poolname2 eu.blockmasters.co:3333\n" + "global username2 LeBekLf38PX2iWmRX1jJY3y9jjasV2eMLP\n" + "global poolpass2 c=LTC\n" + "global sendworker2 yes\n" + "global poolname3 coins.prohashing.com:3333\n" + "global username3 miningxxx\n" + "global poolpass3 c=Litecoin k=e9b3d7f181bd2369769867884cb12a575c946bd21c367b1f4b6858f5451506da\n" + "global sendworker3 yes\n\n" + "global panelclear 5\n" + "global asicboost no\n" + "global autotune yes\n" + "global maxwatts 1480\n" + "global hpc 97\n\n" + "global autoupdate yes\n" + "global allowed yes\n" + "global blinkgreen off\n" + "global blinkred off\n\n" + "global maxtemp 90\n" + "global fansaver 55\n" + "global fanspeed 20\n\n" + "global retune 1\n" + "global retune 2\n" + "global retune 3\n" + "global rebootasic 1\n" + "global rebootasic 2\n" + "global rebootasic 3\n" + "global resetasic 1\n" + "global resetasic 2\n" + "global resetasic 3\n" + "# global panelpass gj83Nkgikg\n\n" + "group=rowc rebootasic 1\n" + "group=rowd allowed no\n\n" + "# ab34ef location rowc2\n\n" + "## vlans\n" + "vlan 10.0.3.0-255\n" + "vlan 10.0.4.0-255\n" + "vlan 10.0.5.0-255\n" + "vlan 10.0.6.0-255\n" + "vlan 10.0.7.0-255\n\n" + "## asic password\n" + "asicpass admin\n\n" + "0bfc61 [setting] [value] # 10.0.3.55 055 s-ago:1396 \n" + "174c32 [setting] [value] # 10.0.3.220 044 s-ago:1396 \n" + "0ca26a [setting] [value] # 10.0.3.45 045 s-ago:1428 \n" + "2a2e36 [setting] [value] # 10.0.3.210 046 s-ago:1457 \n" + "a2e9eb [setting] [value] # 10.0.3.215 047 s-ago:1457 \n" + "b9ef87 [setting] [value] # 10.0.3.50 050 s-ago:1462 \n" + "9b2c4f [setting] [value] # 10.0.3.49 049 s-ago:1473 \n" + "fa216b [setting] [value] # 10.0.3.030 230 s-ago:1477 \n" + "691c8e [setting] [value] # 10.0.3.70 224 s-ago:1586 \n" + "f75716 [setting] [value] # 10.0.3.44 244 s-ago:1591 \n" + "1866a4 [setting] [value] # 10.0.3.54 254 s-ago:1600 \n" + "c073b8 [setting] [value] # 10.0.3.219 025 s-ago:1602 \n" + "c6459d [setting] [value] # 10.0.3.225 225 s-ago:1605 \n" + "473676 [setting] [value] # 10.0.3.60 026 s-ago:1606 \n" + "a8315c [setting] [value] # 10.0.3.53 053 s-ago:1611 \n" + "e68e04 [setting] [value] # 10.0.3.218 027 s-ago:1614 \n" + "d27556 [setting] [value] # 10.0.3.59 017 s-ago:1616 \n" + "c2c141 [setting] [value] # 10.0.3.205 018 s-ago:1632 \n" + "80cbe7 [setting] [value] # 10.0.3.224 224 s-ago:1634 \n" + "2be5c0 [setting] [value] # 10.0.3.48 048 s-ago:1636 \n" + "1b667b [setting] [value] # 10.0.3.214 021 s-ago:1637 \n" + "3d05c9 [setting] [value] # 10.0.3.209 022 s-ago:1640 \n" + "351579 [setting] [value] # 10.0.3.228 228 s-ago:1642 \n" + "7508e2 [setting] [value] # 10.0.3.229 229 s-ago:1644 \n" + "0e3991 [setting] [value] # 10.0.3.52 052 s-ago:1647 \n" + "529b2e [setting] [value] # 10.0.3.64 026 s-ago:1651 \n" + "90a1ec [setting] [value] # 10.0.3.69 027 s-ago:1653 \n" + "dae87b [setting] [value] # 10.0.3.65 028 s-ago:1658 \n" + "656849 [setting] [value] # 10.0.3.213 029 s-ago:1760 \n" + "196fe8 [setting] [value] # 10.0.3.204 204 s-ago:1769 \n" + "d04421 [setting] [value] # 10.0.3.212 031 s-ago:1773 \n" + "96b709 [setting] [value] # 10.0.3.217 032 s-ago:1777 \n" + "40f1a4 [setting] [value] # 10.0.3.66 033 s-ago:1784 \n" + "27cad7 [setting] [value] # 10.0.3.51 051 s-ago:1788 \n" + "da321d [setting] [value] # 10.0.3.57 057 s-ago:1791 \n" + "619b76 [setting] [value] # 10.0.3.43 043 s-ago:1794 \n" + "acfec2 [setting] [value] # 10.0.3.58 058 s-ago:1802 \n" + "0c6d2f [setting] [value] # 10.0.3.63 138 s-ago:1802 \n" + "f1485a [setting] [value] # 10.0.3.207 239 s-ago:1804 \n" + "c44b94 [setting] [value] # 10.0.3.208 240 s-ago:1807 \n" + "227a2d [setting] [value] # 10.0.3.46 046 s-ago:1807 \n" + "cca2db [setting] [value] # 10.0.3.227 227 s-ago:1808 \n" + "60c3a2 [setting] [value] # 10.0.3.223 223 s-ago:1811 \n" + "781a92 [setting] [value] # 10.0.3.222 222 s-ago:1835 \n" + "ae5fa6 [setting] [value] # 10.0.3.203 145 s-ago:1837 \n" + "3c271f [setting] [value] # 10.0.3.67 146 s-ago:1839 \n" + "81beae [setting] [value] # 10.0.3.47 047 s-ago:1840 \n" + "882c88 [setting] [value] # 10.0.3.42 042 s-ago:1850 \n" + "f64b7b [setting] [value] # 10.0.3.221 221 s-ago:85504 \n" + "6a7f19 [setting] [value] # 10.0.3.41 041 s-ago:122108 \n" + "27ff38 [setting] [value] # 10.0.3.56 056 s-ago:118254 \n" + "70a371 [setting] [value] # 10.0.3.226 226 s-ago:108091 "; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); 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