Regular Expressions 101

Save & Share

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

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)(?P<key>\w+) = (?P<val>[^\\]+)" Local $sString = "{"global_quality": "[general]\" & @CRLF & _ "version = 4\" & @CRLF & _ "name = Benchy Jonas\" & @CRLF & _ "definition = fdmprinter\" & @CRLF & _ "\" & @CRLF & _ "[metadata]\" & @CRLF & _ "setting_version = 6\" & @CRLF & _ "type = quality_changes\" & @CRLF & _ "quality_type = normal\" & @CRLF & _ "\" & @CRLF & _ "[values]\" & @CRLF & _ "acceleration_enabled = True\" & @CRLF & _ "adhesion_type = skirt\" & @CRLF & _ "bridge_settings_enabled = True\" & @CRLF & _ "jerk_enabled = False\" & @CRLF & _ "layer_height = 0.2\" & @CRLF & _ "layer_height_0 = 0.2\" & @CRLF & _ "magic_spiralize = False\" & @CRLF & _ "material_bed_temperature = 50\" & @CRLF & _ "material_bed_temperature_layer_0 = 50\" & @CRLF & _ "retraction_combing = infill\" & @CRLF & _ "speed_slowdown_layers = 1\" & @CRLF & _ "support_enable = True\" & @CRLF & _ "support_type = buildplate\" & @CRLF & _ "travel_retract_before_outer_wall = True\" & @CRLF & _ "\" & @CRLF & _ "", "extruder_quality": ["[general]\" & @CRLF & _ "version = 4\" & @CRLF & _ "name = Benchy Jonas\" & @CRLF & _ "definition = fdmprinter\" & @CRLF & _ "\" & @CRLF & _ "[metadata]\" & @CRLF & _ "setting_version = 6\" & @CRLF & _ "type = quality_changes\" & @CRLF & _ "quality_type = normal\" & @CRLF & _ "position = 0\" & @CRLF & _ "\" & @CRLF & _ "[values]\" & @CRLF & _ "acceleration_infill = 1000\" & @CRLF & _ "acceleration_print = 500\" & @CRLF & _ "acceleration_roofing = 750\" & @CRLF & _ "acceleration_topbottom = 1000\" & @CRLF & _ "acceleration_travel = 1500\" & @CRLF & _ "acceleration_wall_0 = 500\" & @CRLF & _ "acceleration_wall_x = 750\" & @CRLF & _ "alternate_extra_perimeter = False\" & @CRLF & _ "bottom_layers = =999999 if infill_sparse_density == 100 else math.ceil(round(bottom_thickness / resolveOrValue('layer_height'), 4))\" & @CRLF & _ "bottom_skin_preshrink = 1.4\" & @CRLF & _ "bottom_thickness = 1.2\" & @CRLF & _ "bridge_fan_speed = 75\" & @CRLF & _ "bridge_fan_speed_2 = 25\" & @CRLF & _ "bridge_fan_speed_3 = 33\" & @CRLF & _ "brim_line_count = 2\" & @CRLF & _ "brim_outside_only = False\" & @CRLF & _ "coasting_enable = False\" & @CRLF & _ "coasting_speed = 100\" & @CRLF & _ "coasting_volume = 0.02\" & @CRLF & _ "cool_fan_full_layer = 5\" & @CRLF & _ "cool_fan_speed = 75\" & @CRLF & _ "cool_fan_speed_max = =cool_fan_speed\" & @CRLF & _ "cool_min_layer_time = 5\" & @CRLF & _ "cool_min_layer_time_fan_speed_max = 20\" & @CRLF & _ "cool_min_speed = 20\" & @CRLF & _ "default_material_print_temperature = 230\" & @CRLF & _ "fill_outline_gaps = False\" & @CRLF & _ "gradual_infill_step_height = 2\" & @CRLF & _ "gradual_infill_steps = 0\" & @CRLF & _ "gradual_support_infill_step_height = 3\" & @CRLF & _ "gradual_support_infill_steps = 1\" & @CRLF & _ "infill_before_walls = False\" & @CRLF & _ "infill_enable_travel_optimization = True\" & @CRLF & _ "infill_line_distance = =0 if infill_sparse_density == 0 else (infill_line_width * 100) / infill_sparse_density * (2 if infill_pattern == 'grid' else (3 if infill_pattern == 'triangles' or infill_pattern == 'trihexagon' or infill_pattern == 'cubic' or infill_pattern == 'cubicsubdiv' else (2 if infill_pattern == 'tetrahedral' or infill_pattern == 'quarter_cubic' else (1 if infill_pattern == 'cross' or infill_pattern == 'cross_3d' else 1))))\" & @CRLF & _ "infill_line_width = 0.5\" & @CRLF & _ "infill_overlap = 5\" & @CRLF & _ "infill_pattern = gyroid\" & @CRLF & _ "infill_sparse_density = 7\" & @CRLF & _ "infill_support_angle = 75\" & @CRLF & _ "infill_support_enabled = False\" & @CRLF & _ "ironing_flow = 8\" & @CRLF & _ "ironing_inset = 0.25\" & @CRLF & _ "ironing_line_spacing = 0.2\" & @CRLF & _ "jerk_infill = 20\" & @CRLF & _ "jerk_layer_0 = 7\" & @CRLF & _ "jerk_print = 7\" & @CRLF & _ "jerk_roofing = 10\" & @CRLF & _ "jerk_support_infill = 20\" & @CRLF & _ "jerk_support_interface = 20\" & @CRLF & _ "jerk_topbottom = 20\" & @CRLF & _ "jerk_travel = 20\" & @CRLF & _ "jerk_travel_layer_0 = 7\" & @CRLF & _ "jerk_wall_0 = 8\" & @CRLF & _ "jerk_wall_x = 15\" & @CRLF & _ "line_width = =machine_nozzle_size\" & @CRLF & _ "material_diameter = 1.75\" & @CRLF & _ "material_final_print_temperature = =max(-273.15, material_print_temperature - 15)\" & @CRLF & _ "material_flow = 99\" & @CRLF & _ "material_initial_print_temperature = =max(-273.15, material_print_temperature - 10)\" & @CRLF & _ "material_print_temperature = 230\" & @CRLF & _ "material_print_temperature_layer_0 = 230\" & @CRLF & _ "min_infill_area = 10\" & @CRLF & _ "optimize_wall_printing_order = True\" & @CRLF & _ "retract_at_layer_change = False\" & @CRLF & _ "retraction_amount = 0.8\" & @CRLF & _ "retraction_count_max = 100\" & @CRLF & _ "retraction_extra_prime_amount = 0\" & @CRLF & _ "retraction_extrusion_window = =retraction_amount\" & @CRLF & _ "retraction_hop = 0.2\" & @CRLF & _ "retraction_hop_enabled = True\" & @CRLF & _ "retraction_hop_only_when_collides = True\" & @CRLF & _ "retraction_min_travel = 1\" & @CRLF & _ "retraction_prime_speed = 25\" & @CRLF & _ "retraction_retract_speed = 25\" & @CRLF & _ "retraction_speed = 70\" & @CRLF & _ "roofing_layer_count = 0\" & @CRLF & _ "roofing_pattern = concentric\" & @CRLF & _ "skin_no_small_gaps_heuristic = False\" & @CRLF & _ "skin_overlap = =5 if top_bottom_pattern != 'concentric' else 0\" & @CRLF & _ "skirt_brim_line_width = =line_width\" & @CRLF & _ "skirt_brim_minimal_length = 175\" & @CRLF & _ "skirt_brim_speed = 20\" & @CRLF & _ "skirt_gap = 5\" & @CRLF & _ "skirt_line_count = 3\" & @CRLF & _ "speed_equalize_flow_enabled = False\" & @CRLF & _ "speed_equalize_flow_max = 60\" & @CRLF & _ "speed_infill = 50\" & @CRLF & _ "speed_ironing = 60\" & @CRLF & _ "speed_layer_0 = 20\" & @CRLF & _ "speed_print = 50\" & @CRLF & _ "speed_roofing = 50\" & @CRLF & _ "speed_support = 50\" & @CRLF & _ "speed_support_infill = 60\" & @CRLF & _ "speed_support_interface = 50\" & @CRLF & _ "speed_topbottom = 50\" & @CRLF & _ "speed_travel = 175\" & @CRLF & _ "speed_wall = =speed_print / 2\" & @CRLF & _ "speed_wall_0 = 25\" & @CRLF & _ "speed_wall_x = =speed_wall * 2\" & @CRLF & _ "support_angle = 67\" & @CRLF & _ "support_infill_rate = 10\" & @CRLF & _ "support_infill_sparse_thickness = =resolveOrValue('layer_height')\" & @CRLF & _ "support_interface_density = 50\" & @CRLF & _ "support_interface_enable = True\" & @CRLF & _ "support_interface_pattern = lines\" & @CRLF & _ "support_interface_skip_height = 0.2\" & @CRLF & _ "support_line_width = 0.5\\nsupport_minimal_diameter = 2\" & @CRLF & _ "support_offset = 0.4\" & @CRLF & _ "support_pattern = zigzag\" & @CRLF & _ "support_roof_height = 1\" & @CRLF & _ "support_top_distance = =extruderValue(support_roof_extruder_nr if support_roof_enable else support_infill_extruder_nr, 'support_z_distance')\" & @CRLF & _ "support_tower_diameter = 5\" & @CRLF & _ "support_tower_roof_angle = 30\" & @CRLF & _ "support_use_towers = True\" & @CRLF & _ "support_wall_count = 1\" & @CRLF & _ "support_xy_distance = 0.6\" & @CRLF & _ "support_xy_distance_overhang = 0.5\" & @CRLF & _ "support_xy_overrides_z = xy_overrides_z\" & @CRLF & _ "support_z_distance = 0.2\" & @CRLF & _ "top_bottom_pattern = lines\" & @CRLF & _ "top_bottom_pattern_0 = lines\" & @CRLF & _ "top_bottom_thickness = 1.6\" & @CRLF & _ "top_layers = =0 if infill_sparse_density == 100 else math.ceil(round(top_thickness / resolveOrValue('layer_height'), 4))\" & @CRLF & _ "top_skin_preshrink = 1.2\" & @CRLF & _ "top_thickness = 1.6\\ntravel_avoid_other_parts = False\" & @CRLF & _ "travel_avoid_supports = True\" & @CRLF & _ "travel_compensate_overlapping_walls_0_enabled = =travel_compensate_overlapping_walls_enabled\" & @CRLF & _ "travel_compensate_overlapping_walls_enabled = False\" & @CRLF & _ "travel_compensate_overlapping_walls_x_enabled = =travel_compensate_overlapping_walls_enabled\" & @CRLF & _ "wall_0_wipe_dist = =machine_nozzle_size / 2\" & @CRLF & _ "wall_line_count = 3\" & @CRLF & _ "wall_line_width_0 = 0.4\" & @CRLF & _ "wall_line_width_x = =wall_line_width\" & @CRLF & _ "wall_thickness = 2\" & @CRLF & _ "xy_offset_layer_0 = -0.05\" & @CRLF & _ "z_seam_corner = z_seam_corner_inner\" & @CRLF & _ "z_seam_relative = True\" & @CRLF & _ "z_seam_type = back\" & @CRLF & _ "z_seam_x = -250\" & @CRLF & _ "z_seam_y = -30\" & @CRLF & _ "\" & @CRLF & _ ""]}" & @CRLF & _ "" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm