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

/
/
is

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 = "\"(PaintKit_sp_nukestripe_green_Tag)\"\\s+\"(.*?)\""; final String string = " \"PaintKit_Default\" \"Unnamed Paint Kit\"\n" + " \"PaintKit_Default_Tag\" \"-\"//\n\n" + " \n" + " \"PaintKit_so_yellow\" \"It has individual parts spray-painted solid colors in a production line yellow color scheme.\"\n" + " \"PaintKit_so_yellow_Tag\" \"Bulldozer\"\n" + " \n" + " \"PaintKit_so_red\" \"It has individual parts spray-painted solid colors in a red and black color scheme.\"\n" + " \"PaintKit_so_red_Tag\" \"Red\"\n" + " \n" + " \"PaintKit_so_purple\" \"It has individual parts spray-painted solid colors in a black and purple color scheme.\"\n" + " \"PaintKit_so_purple_Tag\" \"Ultraviolet\"\n" + " \n" + " \"PaintKit_so_night\" \"It has individual parts spray-painted solid colors in a night ops color scheme.\"\n" + " \"PaintKit_so_night_Tag\" \"Night\"\n\n" + " \"PaintKit_so_caramel\" \"It has individual parts spray-painted solid colors in a caramel and black color scheme.\"\n" + " \"PaintKit_so_caramel_Tag\" \"Caramel\"\n" + " \n" + " \"PaintKit_so_grassland\" \"It has individual parts spray-painted solid colors in a grassland color scheme.\"\n" + " \"PaintKit_so_grassland_Tag\" \"Grassland\"\n" + " \n" + " \"PaintKit_so_sand\" \"It has individual parts spray-painted solid colors in a sand dune color scheme.\"\n" + " \"PaintKit_so_sand_Tag\" \"Sand Dune\"\n" + " \n" + " \"PaintKit_so_tornado\" \"It has individual parts spray-painted solid colors in a tornado color scheme.\"\n" + " \"PaintKit_so_tornado_Tag\" \"Tornado\"\n" + " \n" + " \"PaintKit_so_whiteout\" \"It is spray-painted all white.\"\n" + " \"PaintKit_so_whiteout_Tag\" \"Whiteout\"\n" + " \n" + " \"PaintKit_so_jungle\" \"It has individual parts spray-painted solid colors in a jungle color scheme.\"\n" + " \"PaintKit_so_jungle_Tag\" \"Jungle\"\n" + " \n" + " \"PaintKit_so_tangerine\" \"It has individual parts spray-painted black and tangerine orange.\"\n" + " \"PaintKit_so_tangerine_Tag\" \"Demolition\"\n" + " \n" + " \"PaintKit_cu_catskulls_p90\" \"It has been hydro-dipped with a graphic of overlapping cat skulls.\"\n" + " \"PaintKit_cu_catskulls_p90_Tag\" \"Death by Kitty\"\n" + " \"PaintKit_CSGO_Doomkitty_Tag\" \"Doomkitty\"\n" + " \n" + " \"PaintKit_hy_ddpat\" \"It has been painted using a Digital Disruptive Pattern (DDPAT) hydrographic.\"\n" + " \"PaintKit_hy_ddpat_Tag\" \"Forest DDPAT\"\n" + " \"PaintKit_hy_ddpat_urb_Tag\" \"Urban DDPAT\"\n" + " \"PaintKit_hy_ddpat_orange_Tag\" \"Orange DDPAT\"\n\n" + " \"PaintKit_hy_arctic\" \"It has been painted using an arctic camo hydrographic.\"\n" + " \"PaintKit_hy_arctic_Tag\" \"Arctic Camo\"\n\n" + " \"PaintKit_hy_forest\" \"It has been painted using a forest camouflage hydrographic.\"\n" + " \"PaintKit_hy_forest_Tag\" \"Wood Camo\"\n" + " \"PaintKit_hy_forest_winter_Tag\" \"Winter Forest\"\n" + " \"PaintKit_hy_forest_boreal_Tag\" \"Boreal Forest\"\n\n" + " \"PaintKit_hy_desert\" \"It has been painted using a desert camouflage hydrographic.\"\n" + " \"PaintKit_hy_desert_Tag\" \"Desert Storm\"\n\n" + " \"PaintKit_hy_copperhead\" \"It has been painted using a copperhead snakeskin-patterned hydrographic.\"\n" + " \"PaintKit_hy_copperhead_Tag\" \"Copperhead\"\n\n" + " \"PaintKit_hy_skulls\" \"It has been painted using a skull-patterned hydrographic with red or black accents.\"\n" + " \"PaintKit_hy_skulls_Tag\" \"Skulls\"\n\n" + " \"PaintKit_hy_webs\" \"It has been painted using a spider web-patterned hydrographic over a red base coat and finished with a semi-gloss topcoat.\"\n" + " \"PaintKit_hy_webs_Tag\" \"Crimson Web\"\n\n" + " \"PaintKit_hy_ak47lam\" \"It has been given a laminate stock.\"\n" + " \"PaintKit_hy_ak47lam_Tag\" \"Red Laminate\"\n" + " \"PaintKit_hy_ak47lam_bw_Tag\" \"Black Laminate\"\n\n" + " \"PaintKit_hy_gelpen\" \"It has been painted using a hydrographic of a gel pen doodle.\"\n" + " \"PaintKit_hy_gelpen_Tag\" \"Gunsmoke\"\n\n" + " \"PaintKit_hy_v_tiger\" \"It has been painted using a jungle tiger hydrographic.\"\n" + " \"PaintKit_hy_v_tiger_Tag\" \"Jungle Tiger\"\n\n" + " \"PaintKit_hy_granite\" \"It has been painted in a marbleized pattern.\"\n" + " \"PaintKit_hy_blizzard_Tag\" \"Blizzard Marbleized\"\n\n" + " \"PaintKit_sp_spray\" \"It has been spray-painted freehand with short, thick lines in contrasting colors.\"\n" + " \"PaintKit_sp_spray_Tag\" \"Contrast Spray\"\n" + " \"PaintKit_sp_spray_jungle_Tag\" \"Jungle Spray\"\n\n" + " \"PaintKit_sp_tape_dots\" \"It has been spray-painted using ripped tape strips and perforated metal as stencils.\"\n" + " \"PaintKit_sp_tape_dots_urban_Tag\" \"Urban Perforated\"\n\n" + " \"PaintKit_sp_leaves\" \"It has been spray-painted using leaves as stencils.\"\n" + " \"PaintKit_sp_leaves_Tag\" \"Forest Leaves\"\n\n" + " \"PaintKit_sp_short_tape\" \"It has been spray-painted using short pieces of tape as stencils.\"\n" + " \"PaintKit_sp_short_tape_Tag\" \"Lichen Dashed\"\n" + " \"PaintKit_sp_short_tape_urban_Tag\" \"Urban Dashed\"\n\n" + " \"PaintKit_sp_tape\" \"It has been spray-painted using a tangle of spray-paint as a stencil.\"\n\n" + " \"PaintKit_sp_tape_urban_Tag\" \"Urban Masked\"\n\n\n" + " \"PaintKit_sp_mesh\" \"It has been spray-painted using mesh fencing and cardboard cutouts as stencils.\"\n" + " \"PaintKit_sp_mesh_tan_Tag\" \"Safari Mesh\"\n" + " \"PaintKit_sp_mesh_glacier_Tag\" \"Glacier Mesh\"\n\n" + " \"PaintKit_sp_snake\" \"It has been spray-painted using a snakeskin stencil in patches that have been outlined freehand.\"\n" + " \"PaintKit_sp_snake_Tag\" \"Snake Camo\"\n" + " \n" + " \"PaintKit_an_silver\" \"It has been painted with a chrome base coat and candied in transparent silver anodized effect paint.\"\n" + " \"PaintKit_an_silver_Tag\" \"Silver\"\n" + " \n" + " \"PaintKit_an_red\" \"It has been painted with a chrome base coat and candied in transparent red anodized effect paint.\"\n" + " \"PaintKit_an_red_Tag\" \"Hot Rod\"\n" + " \n" + " \"PaintKit_an_navy\" \"It has been painted with a chrome base coat and candied in transparent navy blue anodized effect paint.\"\n" + " \"PaintKit_an_navy_Tag\" \"Anodized Navy\"\n\n" + " \"PaintKit_am_urban\" \"It has been painted using an urban Digital Disruptive Pattern (DDPAT) hydrographic over a metallic base coat.\"\n" + " \"PaintKit_am_urban_Tag\" \"Metallic DDPAT\"\n\n" + " \"PaintKit_am_tiger\" \"It has been gold-plated and hand-etched in a tiger stripe pattern.\"\n" + " \"PaintKit_am_tiger_Tag\" \"Gold Tiger\"\n" + " \n" + " \"PaintKit_am_dragon_glock\" \"It has been painted using a dragon decal over a metallic base coat.\"\n" + " \"PaintKit_am_dragon_glock_Tag\" \"Dragon Tattoo\"\n" + " \n" + " \"PaintKit_am_caustics\" \"It has been painted using a red and white hydrographic over a charcoal metallic base coat.\"\n" + " \"PaintKit_am_caustics_Tag\" \"Caustics\"\n" + " \n" + " \"PaintKit_am_lightning_awp\" \"It has been painted with a lightning strike motif using anodizing effect paints over a metallic base coat.\"\n" + " \"PaintKit_am_lightning_awp_Tag\" \"Lightning Strike\"\n\n" + " \"PaintKit_am_ossify\" \"It has been painted using a transparent lime green abstract hydrographic over a metallic base coat.\"\n" + " \"PaintKit_am_ossify_Tag\" \"Ossified\"\n\n" + " \"PaintKit_aa_flames\" \"It has been painted by airbrushing transparent paints over a chrome base coat.\"\n" + " \"PaintKit_aa_flames_Tag\" \"Blaze\"\n" + " \n" + " \"PaintKit_aa_splash_p250\" \"It has been painted by airbrushing transparent paints through a stencil over a chrome base coat.\"\n" + " \"PaintKit_aa_splash_p250_Tag\" \"Splash\"\n\n" + " \"PaintKit_aa_fade\" \"It has been painted by airbrushing transparent paints that fade together over a chrome base coat.\"\n" + " \"PaintKit_aa_fade_Tag\" \"Fade\"\n\n" + " \"PaintKit_aq_copper\" \"It has been copper plated.\"\n" + " \"PaintKit_aq_copper_Tag\" \"Copper\"\n\n" + " \"PaintKit_aq_blued\" \"It has been cold blued.\"\n" + " \"PaintKit_aq_blued_Tag\" \"Blue Steel\"\n\n" + " \"PaintKit_aq_forced\" \"It has been given a forced patina using lemon and mustard dripped onto the surface.\"\n" + " \"PaintKit_aq_forced_Tag\" \"Stained\"\n\n" + " \"PaintKit_aq_oiled\" \"It has been color case-hardened through the application of wood charcoal at high temperatures.\"\n" + " \"PaintKit_aq_oiled_Tag\" \"Case Hardened\"\n" + " \"PaintKit_am_zebra\" \"It has been painted in a zebra-stripe pattern with aluminum and chrome paints with various reflectivities, and has then been covered with a tomato red candy coat.\"\n" + " \"PaintKit_am_zebra_Tag\" \"Slaughter\"\n" + " \n" + " \"PaintKit_am_zebra_dark\" \"It has been painted in an aquatic-stripe pattern with charcoal metallic paints of various reflectivities over a chrome base coat.\"\n" + " \"PaintKit_am_zebra_dark_Tag\" \"Dark Water\"\n" + " \n" + " \"PaintKit_aa_vertigo\" \"It has been painted with a pearl base coat, then spray-painted black through a stencil in a graphic pattern.\"\n" + " \"PaintKit_aa_vertigo_Tag\" \"Hypnotic\"\n" + " \n" + " \"PaintKit_aq_rust\" \"Although the exterior surfaces have rusted, this firearm is still perfectly operational.\"\n" + " \"PaintKit_aq_rust_Tag\" \"Rusty\"\n" + " \n" + " \"PaintKit_am_carbon_fiber\" \"It has been painted using a carbon fiber hydrographic over a graphite base coat.\"\n" + " \"PaintKit_am_carbon_fiber_Tag\" \"Carbon Fiber\"\n" + " \n" + " \"PaintKit_am_scorpion_p2000\" \"It has been painted using anodized-effect paints in a rippled fade pattern with a red scorpion decal on the grip.\"\n" + " \"PaintKit_am_scorpion_p2000_Tag\" \"Scorpion\"\n" + " \n" + " \"PaintKit_hy_feathers_aug\" \"It has been decorated with dry-transfer decals of eagle feathers.\"\n" + " \"PaintKit_hy_feathers_aug_Tag\" \"Wings\"\n" + " \n" + " \"Paintkit_sp_palm\" \"It has been spray-painted using cardboard cutouts, fine mesh, and palm leaves as stencils.\"\n" + " \"Paintkit_sp_palm_Tag\" \"Palm\"\n" + " \n" + " \"PaintKit_cu_walnut_nova\" \"It has a figured walnut stock.\"\n" + " \"PaintKit_cu_walnut_nova_Tag\" \"Walnut\"\n" + " \n" + " \"PaintKit_aq_brass\" \"It has brass parts.\"\n" + " \"PaintKit_aq_brass_Tag\" \"Brass\"\n" + " \n" + " \"PaintKit_hy_blam\" \"It has been painted using a hydrographic printed with comic book onomatopoeia over an orange base coat.\"\n" + " \"PaintKit_hy_blam_Tag\" \"KABOOM!\"\n" + " \"PaintKit_hy_blam_simple_Tag\" \"BOOM\"\n\n" + " \"PaintKit_sp_dapple\" \"It has been spray-painted in a sun-dappled pattern.\"\n" + " \"PaintKit_sp_dapple_Tag\" \"Scorched\"\n" + " \n" + " \"PaintKit_sp_splash_p250\" \"It has been spray-painted and decorated using a splash-shaped stencil.\"\n" + " \"PaintKit_sp_splash_p250_Tag\" \"Splash\"\n" + " \n" + " \"PaintKit_hy_hunter_modern\" \"It has been painted using a photographic hunting camo hydrographic.\"\n" + " \"PaintKit_hy_hunter_modern_Tag\" \"Modern Hunter\"\n" + " \"PaintKit_hy_hunter_blaze_pink_Tag\" \"Splash Jam\"\n" + " \"PaintKit_hy_hunter_blaze_orange_Tag\" \"Blaze Orange\"\n" + " \n" + " \"PaintKit_sp_nukestripe\" \"It has been spray-painted with radiological warning hazard patterns.\"\n" + " \"PaintKit_sp_nukestripe_brown_Tag\" \"Irradiated Alert\"\n" + " \"PaintKit_sp_nukestripe_maroon_Tag\" \"Fallout Warning\"\n" + " \"PaintKit_sp_nukestripe_orange_Tag\" \"Radiation Hazard\"\n" + " \"PaintKit_sp_nukestripe_green_Tag\" \"Nuclear Threat\"\n" + " \n" + " \"PaintKit_sp_zebracam\" \"It has been spray-painted in a zebra stripe pattern.\"\n" + " \"PaintKit_sp_zebracam_Tag\" \"Predator\"\n" + " \"PaintKit_sp_zebracam_bw_Tag\" \"Faded Zebra\"\n" + " \n" + " \"PaintKit_CSGO_Camo\" \"It has been painted using a hydrographic in the Global Offensive camo pattern.\"\n" + " \"PaintKit_CSGO_Camo_Tag\" \"GO Camo\"\n" + " \n" + " \"PaintKit_CSGO_Icosahedron\" \"It has been painted using a geometric-patterned hydrographic.\"\n" + " \"PaintKit_CSGO_Icosahedron_Tag\" \"Memento\""; final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL); final Matcher matcher = pattern.matcher(string); if (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