Regular Expressions 101

Save & Share

  • Regex Version: ver. 9
  • 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

r"
"
gm

Test String

Code Generator

Generated Code

# coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r"\n?;SETTING_3 " test_str = (";SETTING_3 {\"global_quality\": \"[general]\\\n" "version = 4\\\n" "name = Benchy Jonas\\\n" "d\n" ";SETTING_3 efinition = fdmprinter\\\n" "\\\n" "[metadata]\\\n" "setting_version = 6\\\n" "type =\n" ";SETTING_3 quality_changes\\\n" "quality_type = normal\\\n" "\\\n" "[values]\\\n" "acceleration\n" ";SETTING_3 _enabled = True\\\n" "adhesion_type = skirt\\\n" "bridge_settings_enabled = T\n" ";SETTING_3 rue\\\n" "jerk_enabled = False\\\n" "layer_height = 0.2\\\n" "layer_height_0 = 0.\n" ";SETTING_3 2\\\n" "magic_spiralize = False\\\n" "material_bed_temperature = 50\\\n" "materia\n" ";SETTING_3 l_bed_temperature_layer_0 = 50\\\n" "retraction_combing = infill\\\n" "speed_\n" ";SETTING_3 slowdown_layers = 1\\\n" "support_enable = True\\\n" "support_type = buildpla\n" ";SETTING_3 te\\\n" "travel_retract_before_outer_wall = True\\\n" "\\\n" "\", \"extruder_qualit\n" ";SETTING_3 y\": [\"[general]\\\n" "version = 4\\\n" "name = Benchy Jonas\\\n" "definition = fd\n" ";SETTING_3 mprinter\\\n" "\\\n" "[metadata]\\\n" "setting_version = 6\\\n" "type = quality_chang\n" ";SETTING_3 es\\\n" "quality_type = normal\\\n" "position = 0\\\n" "\\\n" "[values]\\\n" "acceleratio\n" ";SETTING_3 n_infill = 1000\\\n" "acceleration_print = 500\\\n" "acceleration_roofing = 7\n" ";SETTING_3 50\\\n" "acceleration_topbottom = 1000\\\n" "acceleration_travel = 1500\\\n" "acc\n" ";SETTING_3 eleration_wall_0 = 500\\\n" "acceleration_wall_x = 750\\\n" "alternate_extra_\n" ";SETTING_3 perimeter = False\\\n" "bottom_layers = =999999 if infill_sparse_density \n" ";SETTING_3 == 100 else math.ceil(round(bottom_thickness / resolveOrValue('layer_\n" ";SETTING_3 height'), 4))\\\n" "bottom_skin_preshrink = 1.4\\\n" "bottom_thickness = 1.2\\\n" ";SETTING_3 \n" "bridge_fan_speed = 75\\\n" "bridge_fan_speed_2 = 25\\\n" "bridge_fan_speed_\n" ";SETTING_3 3 = 33\\\n" "brim_line_count = 2\\\n" "brim_outside_only = False\\\n" "coasting_e\n" ";SETTING_3 nable = False\\\n" "coasting_speed = 100\\\n" "coasting_volume = 0.02\\\n" "cool_\n" ";SETTING_3 fan_full_layer = 5\\\n" "cool_fan_speed = 75\\\n" "cool_fan_speed_max = =cool\n" ";SETTING_3 _fan_speed\\\n" "cool_min_layer_time = 5\\\n" "cool_min_layer_time_fan_speed_\n" ";SETTING_3 max = 20\\\n" "cool_min_speed = 20\\\n" "default_material_print_temperature =\n" ";SETTING_3 230\\\n" "fill_outline_gaps = False\\\n" "gradual_infill_step_height = 2\\\n" "g\n" ";SETTING_3 radual_infill_steps = 0\\\n" "gradual_support_infill_step_height = 3\\\n" "gr\n" ";SETTING_3 adual_support_infill_steps = 1\\\n" "infill_before_walls = False\\\n" "infill\n" ";SETTING_3 _enable_travel_optimization = True\\\n" "infill_line_distance = =0 if inf\n" ";SETTING_3 ill_sparse_density == 0 else (infill_line_width * 100) / infill_spars\n" ";SETTING_3 e_density * (2 if infill_pattern == 'grid' else (3 if infill_pattern \n" ";SETTING_3 == 'triangles' or infill_pattern == 'trihexagon' or infill_pattern ==\n" ";SETTING_3 'cubic' or infill_pattern == 'cubicsubdiv' else (2 if infill_pattern\n" ";SETTING_3 == 'tetrahedral' or infill_pattern == 'quarter_cubic' else (1 if inf\n" ";SETTING_3 ill_pattern == 'cross' or infill_pattern == 'cross_3d' else 1))))\\\n" "i\n" ";SETTING_3 nfill_line_width = 0.5\\\n" "infill_overlap = 5\\\n" "infill_pattern = gyroid\n" ";SETTING_3 \\\n" "infill_sparse_density = 7\\\n" "infill_support_angle = 75\\\n" "infill_sup\n" ";SETTING_3 port_enabled = False\\\n" "ironing_flow = 8\\\n" "ironing_inset = 0.25\\\n" "iron\n" ";SETTING_3 ing_line_spacing = 0.2\\\n" "jerk_infill = 20\\\n" "jerk_layer_0 = 7\\\n" "jerk_p\n" ";SETTING_3 rint = 7\\\n" "jerk_roofing = 10\\\n" "jerk_support_infill = 20\\\n" "jerk_suppor\n" ";SETTING_3 t_interface = 20\\\n" "jerk_topbottom = 20\\\n" "jerk_travel = 20\\\n" "jerk_trav\n" ";SETTING_3 el_layer_0 = 7\\\n" "jerk_wall_0 = 8\\\n" "jerk_wall_x = 15\\\n" "line_width = =m\n" ";SETTING_3 achine_nozzle_size\\\n" "material_diameter = 1.75\\\n" "material_final_print_\n" ";SETTING_3 temperature = =max(-273.15, material_print_temperature - 15)\\\n" "materi\n" ";SETTING_3 al_flow = 99\\\n" "material_initial_print_temperature = =max(-273.15, mat\n" ";SETTING_3 erial_print_temperature - 10)\\\n" "material_print_temperature = 230\\\n" "ma\n" ";SETTING_3 terial_print_temperature_layer_0 = 230\\\n" "min_infill_area = 10\\\n" "optim\n" ";SETTING_3 ize_wall_printing_order = True\\\n" "retract_at_layer_change = False\\\n" "re\n" ";SETTING_3 traction_amount = 0.8\\\n" "retraction_count_max = 100\\\n" "retraction_extra\n" ";SETTING_3 _prime_amount = 0\\\n" "retraction_extrusion_window = =retraction_amount\\\n" ";SETTING_3 \n" "retraction_hop = 0.2\\\n" "retraction_hop_enabled = True\\\n" "retraction_h\n" ";SETTING_3 op_only_when_collides = True\\\n" "retraction_min_travel = 1\\\n" "retraction\n" ";SETTING_3 _prime_speed = 25\\\n" "retraction_retract_speed = 25\\\n" "retraction_speed \n" ";SETTING_3 = 70\\\n" "roofing_layer_count = 0\\\n" "roofing_pattern = concentric\\\n" "skin_\n" ";SETTING_3 no_small_gaps_heuristic = False\\\n" "skin_overlap = =5 if top_bottom_pat\n" ";SETTING_3 tern != 'concentric' else 0\\\n" "skirt_brim_line_width = =line_width\\\n" "s\n" ";SETTING_3 kirt_brim_minimal_length = 175\\\n" "skirt_brim_speed = 20\\\n" "skirt_gap = \n" ";SETTING_3 5\\\n" "skirt_line_count = 3\\\n" "speed_equalize_flow_enabled = False\\\n" "spee\n" ";SETTING_3 d_equalize_flow_max = 60\\\n" "speed_infill = 50\\\n" "speed_ironing = 60\\\n" "s\n" ";SETTING_3 peed_layer_0 = 20\\\n" "speed_print = 50\\\n" "speed_roofing = 50\\\n" "speed_sup\n" ";SETTING_3 port = 50\\\n" "speed_support_infill = 60\\\n" "speed_support_interface = 50\\\n" ";SETTING_3 \n" "speed_topbottom = 50\\\n" "speed_travel = 175\\\n" "speed_wall = =speed_pri\n" ";SETTING_3 nt / 2\\\n" "speed_wall_0 = 25\\\n" "speed_wall_x = =speed_wall * 2\\\n" "support\n" ";SETTING_3 _angle = 67\\\n" "support_infill_rate = 10\\\n" "support_infill_sparse_thickn\n" ";SETTING_3 ess = =resolveOrValue('layer_height')\\\n" "support_interface_density = 5\n" ";SETTING_3 0\\\n" "support_interface_enable = True\\\n" "support_interface_pattern = lin\n" ";SETTING_3 es\\\n" "support_interface_skip_height = 0.2\\\n" "support_line_width = 0.5\\\\\n" ";SETTING_3 nsupport_minimal_diameter = 2\\\n" "support_offset = 0.4\\\n" "support_patter\n" ";SETTING_3 n = zigzag\\\n" "support_roof_height = 1\\\n" "support_top_distance = =extrud\n" ";SETTING_3 erValue(support_roof_extruder_nr if support_roof_enable else support_\n" ";SETTING_3 infill_extruder_nr, 'support_z_distance')\\\n" "support_tower_diameter = \n" ";SETTING_3 5\\\n" "support_tower_roof_angle = 30\\\n" "support_use_towers = True\\\n" "suppo\n" ";SETTING_3 rt_wall_count = 1\\\n" "support_xy_distance = 0.6\\\n" "support_xy_distance_o\n" ";SETTING_3 verhang = 0.5\\\n" "support_xy_overrides_z = xy_overrides_z\\\n" "support_z_d\n" ";SETTING_3 istance = 0.2\\\n" "top_bottom_pattern = lines\\\n" "top_bottom_pattern_0 = l\n" ";SETTING_3 ines\\\n" "top_bottom_thickness = 1.6\\\n" "top_layers = =0 if infill_sparse_\n" ";SETTING_3 density == 100 else math.ceil(round(top_thickness / resolveOrValue('l\n" ";SETTING_3 ayer_height'), 4))\\\n" "top_skin_preshrink = 1.2\\\n" "top_thickness = 1.6\\\\\n" ";SETTING_3 ntravel_avoid_other_parts = False\\\n" "travel_avoid_supports = True\\\n" "tr\n" ";SETTING_3 avel_compensate_overlapping_walls_0_enabled = =travel_compensate_over\n" ";SETTING_3 lapping_walls_enabled\\\n" "travel_compensate_overlapping_walls_enabled =\n" ";SETTING_3 False\\\n" "travel_compensate_overlapping_walls_x_enabled = =travel_comp\n" ";SETTING_3 ensate_overlapping_walls_enabled\\\n" "wall_0_wipe_dist = =machine_nozzle\n" ";SETTING_3 _size / 2\\\n" "wall_line_count = 3\\\n" "wall_line_width_0 = 0.4\\\n" "wall_line\n" ";SETTING_3 _width_x = =wall_line_width\\\n" "wall_thickness = 2\\\n" "xy_offset_layer_0 \n" ";SETTING_3 = -0.05\\\n" "z_seam_corner = z_seam_corner_inner\\\n" "z_seam_relative = Tru\n" ";SETTING_3 e\\\n" "z_seam_type = back\\\n" "z_seam_x = -250\\\n" "z_seam_y = -30\\\n" "\\\n" "\"]}\n\n") matches = re.finditer(regex, test_str, re.MULTILINE) for matchNum, match in enumerate(matches, start=1): print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) # Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.

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 Python, please visit: https://docs.python.org/3/library/re.html