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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

/
/
Ugm

Test String

Code Generator

Generated Code

re = /(?!cm)(?<=Raw Va.ue ;)(?P<v1>.*)Raw Va.ue ;(?P<v2>.*)(?=;Penalty)/m str = '1 "Simulator is not connected to SimNowlLink ;teports ;\'ERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT, ;NOTES: ;IDemoUser ;Ring Rollercoaster 1 ;SCORE: ;26 ;88 ;DATE: 09/04/2020 08:20:36 ;Pay attention to all penalties. You ;can improve drops by following this ;advice: ;• handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;SURGICAL\' ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of ;Time to Complete ;Raw Value ;178.0 cm ;129.1 sec. ;50.0 ;50.0 ;Efficiency Subtotat ;Penalties ;Ring Collision Warning (Yellow) ;Ring Excessive Force (Red) ;Instrument-Instrument Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Vatue ;13.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;2.0 ct. ;1.0 ct. ;Penalty Subtotal ;Overall Score ;pts. ;65.3 ;28.9 ;94 ;-1.3 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-4.0 ;-0.3 ;-6 ;88 ;k. ; 2 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;IPtmoUser ;USE R?\' ;Ring Rollercoaster 1 ;EXERCISE: ;ATT ÉivlPT ;27 ;DATE: 09/04/2020 ;SCORE BREAKDOWN\', ;NOTES: ;Really focus on improving drops by ;following these ;0\' handle grasped objectS ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;•j camera clutch to optimize your ;field of view. ;NCH €XERCISE ;INTUITIVE ;SURGICAL v ;SCORE: ;Raw Value ;177.7 cm ;143.4 sec. ;Efficiency hetrics ;Economy bf Åotion ;Time to Complete ;Penalties ;Efficiency Subtotal ;Ring Collision Warning (Yéllow) ;Ring Excessive Force (Red) ;Instrument-Instrument Collisions ;instrument•Endoscope Collisions ;\'Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;14.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.4 sec. ;3.0 ct. ;0.0 ct. ;Max Pts. ;50.0 65.4 ;50.0 23.8 ;89 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-6.0 ;-0.0 ;Penalty Subtotal ;Overall Score ; 3 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT ;NOTES: ;DemoUser ;Ring Rollercoaster 1 ;28 ;DATE: 09/04/2020 ;SCORE: ;95 ;Good job improving drops! Continue ;to follow this advice to score even ;better: ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;Efficiency Subtotal ;Penalties ;Ring Cottision Warning (Yellow) ;Ring Excessive Force (Red) ;Instrument.lnstrument Collisions ;Instrument -Endoscope Collisions ;Endoscope-Environment Collisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;149.5 cm ;101.5 sec. ;Raw Value ;8.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;2.0 ct. ;1.0 ct. ;50.0 ;50.0 ;• ;• ;handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL\' ;Penalty Subtotal ;Overall Score ;pts. ;70.1 ;38.7 ;too ;-0.8 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-4.0 ;.0.3 ;-5 ;95 ; 4 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPT: ;NOTES: ;DemoUser ;Ring Rollercoaster 1 ;29 ;DATE: 09/04/2020 ;SCORE BREAKDOWN: ;Efficiency Metrics ;Economy of Motioh ;Time to Complete ;SCORE: ;Raw Value ;170.8 cm ;138.3 sec. ;Really focus on improving drops by ;following these techniques: ;• handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;• camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL r ;Efficiency Subtotat ;Penalties ;Raw Value ;Ring Collision Warning (Yellow) ;, 14.0 ct. ;0.0 ci. ;Ring Excessive Force (Red) ;Instrument-Instrument Collisions ;0.0 ct. ;Instrument-Endoscope CollisionS ;0.0 ct. ;Endoscope-Environment Collisions ;0.0 ct. ;Excessive Force ;0.0 sec. ;Drops ;5.0 ct. ;Instruments Out of View ;0.0 ct. ;Penalty Subtotal ;Overall Score ;Pts. ;50.0 66.5 ;50.0 25.6 ;92 ;-1.4 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-10.0 ;-0.0 ;-11 ;81 ; 5 "Simulator is not connected to SimNowlLink ;Reports ;PERFORMANCE REPORT ;USER: ;EXERCISE: ;ATTEMPt ;NOTES: ;DemoUser ;Ring Rollercoaster 1 ;31 ;DATE: 09/04/2020 08:33:34 ;SCORE BREAKDOWN: ;SCORE: ;85 ;Good job improving drops! , Continue ;to follow this advice to score, even ;better:, ;• handle grasped objects ;carefully, use the wristed ;instruments to properly position ;object in the grasper. ;• camera clutch to optimize your ;field of view. ;LAUNCH EXERCISE ;INTUITIVE ;SURGICAL r ;Efficiency Metrics ;Economy of Motion ;Time to Complete ;Raw Value ;164.8 cm ;136.6 sec. ;Efficiency Subtotal. ;Penalties ;Ring Collision Warning (Yellow) ;Ring Excessive Force (Red) ;Instrument-instrument Collisions ;Instrument-Endoscope Collisions ;Endoscope-Environment Cottisions ;Excessive Force ;Drops ;Instruments Out of View ;Raw Value ;7.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 ct. ;0.0 sec. ;4.0 ct. ;1.0 ct. ;Penalty Subtotal ;Overall Score ;Pts. ;50.0 67.5 ;50.0 26.2 ;-0.7 ;-0.0 ;-0.0 ;-0.0 ;-0.0 ;-8.0 ;-0.3 ;85 ; ' # Print the match result str.scan(re) do |match| puts match.to_s end

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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html