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
  • 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
No Match

@"
"
gmi

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 = "(?mi)(1\.\d+)\D+?(?:(\S+)\s+)+?(\d+)" Local $sString = " BRIEF CONTENTS" & @CRLF & _ " Chapter1 Basic Concepts 1" & @CRLF & _ " Chapter2 Resistive Circuits 24" & @CRLF & _ " Chapter3 Nodal and Loop Analysis Techniques 89" & @CRLF & _ " Chapter4 Operational Amplifiers 147" & @CRLF & _ " Chapter5 Additional Analysis Techniques 171" & @CRLF & _ " Chapter6 Capacitance and Inductance 219" & @CRLF & _ " Chapter7 First- and Second-Order Transient Circuits 252" & @CRLF & _ " Chapter8 AC Steady-State Analysis 305" & @CRLF & _ " Chapter9 Steady-State Power Analysis 362" & @CRLF & _ " Chapter10 Magnetically Coupled Networks 411" & @CRLF & _ " Chapter11 Polyphase Circuits 450" & @CRLF & _ " Chapter12 Variable-Frequency Network Performance 482" & @CRLF & _ " Chapter13 The Laplace Transform 543" & @CRLF & _ " Chapter14 Application of the Laplace Transform to " & @CRLF & _ " Circuit Analysis 569" & @CRLF & _ " Chapter15 Fourier Analysis Techniques 617" & @CRLF & _ " Appendix Complex Numbers 659" & @CRLF & _ " vi" & @CRLF & _ " FM.indd viFM.indd vi 21/11/14 11:11 AM21/11/14 11:11 AM" & @CRLF & _ " CONTENTS" & @CRLF & _ " Preface ix 5.3 Thévenin’s and Norton’s Theorems  179" & @CRLF & _ " Chapterone 5.4 Maximum Power Transfer  197" & @CRLF & _ " Summary  202" & @CRLF & _ " Basic Concepts 1 Problems  202" & @CRLF & _ " 1.1 System of Units 2 Chaptersix " & @CRLF & _ " 1.2 Basic Quantities 2 Capacitance and Inductance 219" & @CRLF & _ " 1.3 Circuit Elements  8" & @CRLF & _ " Summary  17 6.1 Capacitors  220" & @CRLF & _ " Problems  18 6.2 Inductors  227" & @CRLF & _ " 6.3 Capacitor and Inductor Combinations  236" & @CRLF & _ " Chaptertwo Summary  241" & @CRLF & _ " Resistive Circuits 24 Problems  241" & @CRLF & _ " 2.1 Ohm’s Law  25 Chapterseven " & @CRLF & _ " 2.2 Kirchhoff’s Laws  30 First- and Second-Order Transient Circuits 252" & @CRLF & _ " 2.3 Single-Loop Circuits  38" & @CRLF & _ " 2.4 Single-Node-Pair Circuits  45 7.1 Introduction  253" & @CRLF & _ " 2.5 Series and Parallel Resistor Combinations  50 7.2 First-Order Circuits  254" & @CRLF & _ " 2.6 Wye Delta Transformations  59 7.3 Second-Order Circuits  275" & @CRLF & _ " 2.7 Circuits with Dependent Sources  63 Summary  289" & @CRLF & _ " Summary  68 Problems  289" & @CRLF & _ " Problems  69 Chaptereight " & @CRLF & _ " Chapterthree AC Steady-State Analysis 305" & @CRLF & _ " Nodal and Loop Analysis Techniques 89 8.1 Sinusoids  306" & @CRLF & _ " 3.1 Nodal Analysis  90 8.2 Sinusoidal and Complex Forcing Functions  309" & @CRLF & _ " 3.2 Loop Analysis  111 8.3 Phasors  312" & @CRLF & _ " Summary  128 8.4 Phasor Relationships for Circuit Elements  314" & @CRLF & _ " Problems  129 8.5 Impedance and Admittance  318" & @CRLF & _ " 8.6 Phasor Diagrams  325" & @CRLF & _ " Chapterfour 8.7 Basic Analysis Using Kirchhoff’s Laws  328" & @CRLF & _ " Operational Amplifiers 147 8.8 Analysis Techniques  331" & @CRLF & _ " Summary  344" & @CRLF & _ " 4.1 Introduction  148 Problems  344" & @CRLF & _ " 4.2 Op-Amp Models  148" & @CRLF & _ " 4.3 Fundamental Op-Amp Circuits  154 Chapternine " & @CRLF & _ " Summary  163 Steady-State Power Analysis 362" & @CRLF & _ " Problems  163 9.1 Instantaneous Power  363" & @CRLF & _ " Chapterfi ve 9.2 Average Power  364" & @CRLF & _ " Additional Analysis Techniques 171 9.3 Maximum Average Power Transfer  369" & @CRLF & _ " 9.4 Effective or rms Values  374" & @CRLF & _ " 5.1 Introduction  172 9.5 The Power Factor  377" & @CRLF & _ " 5.2 Superposition  174 9.6 Complex Power  379" & @CRLF & _ " vii" & @CRLF & _ " FM.indd viiFM.indd vii 21/11/14 11:11 AM21/11/14 11:11 AM" & @CRLF & _ " viii CONTENTS" & @CRLF & _ " 9.7 Power Factor Correction  384 13.3 Transform Pairs  547" & @CRLF & _ " 9.8 Single-Phase Three-Wire Circuits  388 13.4 Properties of the Transform  549" & @CRLF & _ " 9.9 Safety Considerations  391 13.5 Performing the Inverse Transform  551" & @CRLF & _ " Summary  399 13.6 Convolution Integral  557" & @CRLF & _ " Problems  399 13.7 Initial-Value and Final-Value Theorems  560" & @CRLF & _ " 13.8 Solving Differential Equations with Laplace " & @CRLF & _ " Chapterten Transforms  562" & @CRLF & _ " Magnetically Coupled Networks 411 Summary  564" & @CRLF & _ " 10.1 Mutual Inductance  412 Problems  564" & @CRLF & _ " 10.2 Energy Analysis  423 Chapterfourteen " & @CRLF & _ " 10.3 The Ideal Transformer  426 Application of the Laplace Transform to " & @CRLF & _ " 10.4 Safety Considerations   436 Circuit Analysis 569" & @CRLF & _ " Summary  437" & @CRLF & _ " Problems  438 14.1 Laplace Circuit Solutions  570" & @CRLF & _ " 14.2 Circuit Element Models  571" & @CRLF & _ " Chaptereleven 14.3 Analysis Techniques  573" & @CRLF & _ " Polyphase Circuits 450 14.4 Transfer Function  586" & @CRLF & _ " 11.1 Three-Phase Circuits  451 14.5 Steady-State Response  603" & @CRLF & _ " 11.2 Three-Phase Connections  456 Summary  606" & @CRLF & _ " 11.3 Source/Load Connections  457 Problems  606" & @CRLF & _ " 11.4 Power Relationships  466 Chapterfi fteen " & @CRLF & _ " 11.5 Power Factor Correction  471 Fourier Analysis Techniques 617" & @CRLF & _ " Summary  475" & @CRLF & _ " Problems  475 15.1 Fourier Series  618" & @CRLF & _ " 15.2 Fourier Transform  641" & @CRLF & _ " Chaptertwelve Summary  651" & @CRLF & _ " Variable-Frequency Network Performance 482 Problems  651" & @CRLF & _ " 12.1 Variable Frequency-Response Analysis  483" & @CRLF & _ " 12.2 Sinusoidal Frequency Analysis  491 Appendix" & @CRLF & _ " 12.3 Resonant Circuits  500 Complex Numbers 659" & @CRLF & _ " 12.4 Scaling  521" & @CRLF & _ " 12.5 Filter Networks  523 Index 666" & @CRLF & _ " Summary  534" & @CRLF & _ " Problems  535" & @CRLF & _ " Chapterthirteen " & @CRLF & _ " The Laplace Transform 543" & @CRLF & _ " 13.1 Definition  544" & @CRLF & _ " 13.2 Two Important Singularity Functions  544" & @CRLF & _ " FM.indd viiiFM.indd viii 21/11/14 11:11 AM21/11/14 11:11 AM" 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