Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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

/
/
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 = "(\\u00a9|\\u00ae|\\u203c|\\u2049|\\u20e3|\\u2122|\\u2139|[\\u2194-\\u2199]|[\\u21a9-\\u21aa]|[\\u231a-\\u231b]|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\u24c2|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|[\\u2600-\\u2604]|\\u260e|\\u2611|[\\u2614-\\u2615]|\\u2618|\\u261d|\\u2620|[\\u2622-\\u2623]|\\u2626|\\u262a|[\\u262e-\\u262f]|[\\u2638-\\u263a]|\\u2640|\\u2642|[\\u2648-\\u2653]|[\\u265f-\\u2660]|\\u2663|[\\u2665-\\u2666]|\\u2668|\\u267b|[\\u267e-\\u267f]|[\\u2692-\\u2697]|\\u2699|[\\u269b-\\u269c]|[\\u26a0-\\u26a1]|\\u26a7|[\\u26aa-\\u26ab]|[\\u26b0-\\u26b1]|[\\u26bd-\\u26be]|[\\u26c4-\\u26c5]|\\u26c8|[\\u26ce-\\u26cf]|\\u26d1|[\\u26d3-\\u26d4]|[\\u26e9-\\u26ea]|[\\u26f0-\\u26f5]|[\\u26f7-\\u26fa]|\\u26fd|\\u2702|\\u2705|[\\u2708-\\u270d]|\\u270f|\\u2712|\\u2714|\\u2716|\\u271d|\\u2721|\\u2728|[\\u2733-\\u2734]|\\u2744|\\u2747|\\u274c|\\u274e|[\\u2753-\\u2755]|\\u2757|[\\u2763-\\u2764]|[\\u2795-\\u2797]|\\u27a1|\\u27b0|\\u27bf|[\\u2934-\\u2935]|[\\u2b05-\\u2b07]|[\\u2b1b-\\u2b1c]|\\u2b50|\\u2b55|\\u3030|\\u303d|\\u3297|\\u3299)|(\\ud83c(\\udc04|\\udccf|[\\udd70-\\udd71]|[\\udd7e-\\udd7f]|\\udd8e|[\\udd91-\\udd9a]|[\\udde6-\\uddff]|[\\ude01-\\ude02]|\\ude1a|\\ude2f|[\\ude32-\\ude3a]|[\\ude50-\\ude51]|[\\udf00-\\udf21]|[\\udf24-\\udf93]|[\\udf96-\\udf97]|[\\udf99-\\udf9b]|[\\udf9e-\\udff0]|[\\udff3-\\udff5]))|(\\ud83d([\\udc00-\\udcfd]|[\\udcff-\\udd3d]|[\\udd49-\\udd4e]|[\\udd50-\\udd67]|[\\udd6f-\\udd70]|[\\udd73-\\udd7a]|\\udd87|[\\udd8a-\\udd8d]|\\udd90|[\\udd95-\\udd96]|[\\udda4-\\udda5]|\\udda8|[\\uddb1-\\uddb2]|\\uddbc|[\\uddc2-\\uddc4]|[\\uddd1-\\uddd3]|[\\udddc-\\uddde]|\\udde1|\\udde3|\\udde8|\\uddef|\\uddf3|[\\uddfa-\\ude4f]|[\\ude80-\\udec5]|[\\udecb-\\uded2]|[\\uded5-\\uded7]|[\\udedd-\\udee5]|\\udee9|[\\udeeb-\\udeec]|\\udef0|[\\udef3-\\udefc]|[\\udfe0-\\udfeb]))|(\\ud83e([\\udd0c-\\udd3a]|[\\udd3c-\\udd45]|[\\udd47-\\uddff]|[\\ude70-\\ude74]|[\\ude78-\\ude7c]|[\\ude80-\\ude86]|[\\ude90-\\udeac]|[\\udeb0-\\udeba]|[\\udec0-\\udec5]|[\\uded0-\\uded9]|[\\udee0-\\udee7]))|(\\udb40([\\udc62-\\udc63]|\\udc65|\\udc67|\\udc6c|\\udc6e|[\\udc73-\\udc74]))"; final String string = "English test\n" + "简体中文测试\n" + "片仮名/かたかな/カタカナ\n" + "平仮名(ひらがな)(hiragana)\n" + "😀 ⚡ ☯ ➿ 🇨🇳 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏃🏼"; 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