Save & Share

  • Current Version: 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to 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 = "\\s+(-[0-9A-Za-z]+|--[A-Za-z0-9][\\w-]+)"; final String string = "ignores position args\n" + "ignores-this _and_this _2 but-not -a -xvzf -4 -6 -Targ\n" + "ignores-echo -----------\n" + "ignores-mistaken --a did-you-mean -a\n" + " --3-2-pulldown\n" + " --3gpp-scan\n" + " --64\n" + " --802_3-sap\n" + " --802_3-type\n" + " --90\n" + " --abi-call0\n" + " --action1\n" + " --action9\n" + " --appData\n" + " --assume-utf16be\n" + " --assume-utf16le\n" + " --authValue\n" + " --aws-sigv4\n" + " --background_compression\n" + " --btf_encode\n" + " --cipherText\n" + " --Complain\n" + " --contains_enumerator\n" + " --data_replicas\n" + " --disable-pcre2-8\n" + " --disable-pcre2grep-callout\n" + " --disable-pcre2grep-callout-fork\n" + " --disable-pcre2grep-jit\n" + " --dns-ipv4-addr\n" + " --dns-ipv6-addr\n" + " --do-0x20-encode\n" + " --do-x20-encode\n" + " --dualprime-mpeg2\n" + " --eccpoint-L\n" + " --enable-ebcdic-nl25\n" + " --enable-never-backslash-C\n" + " --enable-pcre2-16\n" + " --enable-pcre2-32\n" + " --enable-pcre2grep-libbz2\n" + " --enable-pcre2grep-libz\n" + " --enable-pcre2test-libedit\n" + " --enable-pcre2test-libreadline\n" + " --entityPath\n" + " --expect100-timeout\n" + " --exportedData\n" + " --filter-A\n" + " --filter-AAAA\n" + " --filterwin2k\n" + " --force-ipv4\n" + " --force-ipv6\n" + " --force-R5\n" + " --force-V4\n" + " --Foreground\n" + " --fwdownload-mode3\n" + " --fwdownload-mode3-max\n" + " --fwdownload-mode7\n" + " --gb18030\n" + " --GBR\n" + " --hostpubmd5\n" + " --hostpubsha256\n" + " --http0\n" + " --http1\n" + " --http2\n" + " --http2-prior-knowledge\n" + " --http3\n" + " --http3-only\n" + " --ignoreDefinites\n" + " --importData\n" + " --Include\n" + " --intra_dc_prec\n" + " --ip6\n" + " --ip6-destination\n" + " --ip6-destination-port\n" + " --ip6-dport\n" + " --ip6-dst\n" + " --ip6-icmp-type\n" + " --ip6-proto\n" + " --ip6-protocol\n" + " --ip6-source\n" + " --ip6-source-port\n" + " --ip6-sport\n" + " --ip6-src\n" + " --ip6-tclass\n" + " --ipv4\n" + " --ipv6\n" + " --Iraw\n" + " --Istdin\n" + " --Istdout\n" + " --jsonPolicy\n" + " --keep-utf16\n" + " --keyPath\n" + " --lang_exclude\n" + " --Lc\n" + " --Lee\n" + " --linearize-pass1\n" + " --Lmac2\n" + " --Ln\n" + " --logData\n" + " --log-ip6\n" + " --Lx\n" + " --mirror-above-4G\n" + " --mirror-below-4G\n" + " --netfilter6\n" + " --no-0x20-encode\n" + " --no3d\n" + " --no-altscan-mpeg2\n" + " --no-D\n" + " --no-dhcpv4-interface\n" + " --no-dummy-svcd-SOF\n" + " --nr_methods\n" + " --numBytes\n" + " --Numeric\n" + " --nvPath\n" + " --oauth2-bearer\n" + " --omit_journal_replay\n" + " --output-Z1\n" + " --output-Z2\n" + " --p12-charset\n" + " --pathList\n" + " --pathOfKeyToDuplicate\n" + " --pcrIndex\n" + " --pcrList\n" + " --pcrLog\n" + " --pcrValue\n" + " --plainText\n" + " --policyPath\n" + " --policyRef\n" + " --post301\n" + " --post302\n" + " --post303\n" + " --prefer-ata12\n" + " --print0\n" + " --PROG-option\n" + " --proxy1\n" + " --proxy-http2\n" + " --proxy-tls13-ciphers\n" + " --proxy-tlsv1\n" + " --publicKey\n" + " --publicKeyPath\n" + " --qualifyingData\n" + " --quiet-dhcp6\n" + " --quoteInfo\n" + " --readimpliesX\n" + " --reduction-2x2\n" + " --reduction-4x4\n" + " --replay_journal_only\n" + " --searchPath\n" + " --seek_bytes\n" + " --set-recommended-min_free_kbytes\n" + " --S-force\n" + " --size_bytes\n" + " --socks4\n" + " --socks4a\n" + " --socks5\n" + " --socks5-basic\n" + " --socks5-gssapi\n" + " --socks5-gssapi-nec\n" + " --socks5-gssapi-service\n" + " --socks5-hostname\n" + " --sslv2\n" + " --sslv3\n" + " --tls13-ciphers\n" + " --tlsv1\n" + " --tpm2\n" + " --tpm2bPrivate\n" + " --tpm2bPublic\n" + " --type_trans\n" + " --type_transition\n" + " --UCS-2\n" + " --Version\n" + " --warning-exit-0\n" + " --Wext\n" + " --with-pcre2grep-bufsize\n" + " --with-pcre2grep-max-bufsize\n" + " --with-PROG\n" + " --Wnp\n" + " --Wp\n" + " --x11\n" + " --x32\n" + " --x509certData"; 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