Regular Expressions 101

Save & Share

  • Regex Version: ver. 6
  • 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)(at the[\n| ]|from the\n|at[\n| ]|faculty of the[\n| ]|faculty of\n)(\w.+[\n]?\w+[ ]?\w+[ ]?\w+[ ]?\w+[ ]?\w+[^(Jan(uary)?|Sep(tember)?(\s\d{4})?|(,)?|author?|(fulfillment)?|laminates]\w+)" Local $sString = "MIT Sample:" & @CRLF & _ "SOME ASPECTS OF RADIATION INDUCED NUCLEATION IN WATER" & @CRLF & _ "by" & @CRLF & _ "Chih-Ping Tso" & @CRLF & _ "B.Tech., Loughborough University of Technology, United Kingdom" & @CRLF & _ "(1968)" & @CRLF & _ "Submitted in Partial Fulfillment of" & @CRLF & _ "the Requirements for the Degree of" & @CRLF & _ "Master of Science" & @CRLF & _ "at the" & @CRLF & _ "Massachusetts Institute of Technology" & @CRLF & _ "August 1970" & @CRLF & _ "Signature of Author" & @CRLF & _ "Department of Nuclear Engineering" & @CRLF & _ "Certified by" & @CRLF & _ "Thesis Supervisor" & @CRLF & _ "Accepted by" & @CRLF & _ "Chairman, Departmental Committee" & @CRLF & _ "Archives on Graduate Students" & @CRLF & _ "MASS. INST. TECH." & @CRLF & _ "--------------------------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "PROCEDURES AS A PEPPESFNTATICN FOR DATA" & @CRLF & _ "IN A COMPUTER PROGRAM FOR UNDERSTANDING" & @CRLF & _ "NATURAL LANGUAGE" & @CRLF & _ "by" & @CRLF & _ "Terry Winograd" & @CRLF & _ "P.A., The Colorado College" & @CRLF & _ "(1966)" & @CRLF & _ "SUBMITTED IN PARTIAL FULFILLMENT" & @CRLF & _ "OF THE REQUIREMENTS FOR THE" & @CRLF & _ "DEGREE OF DOCTOR OF" & @CRLF & _ "PHILOSOPHY" & @CRLF & _ "at the" & @CRLF & _ "MASSACHUSETTS INSTITUTE OF" & @CRLF & _ "TECHNOLOGY" & @CRLF & _ "August, 1970" & @CRLF & _ "Signature of Author" & @CRLF & _ "Department of Mathematics August 24, 1970" & @CRLF & _ "Certified by" & @CRLF & _ "Thesis Supervisor" & @CRLF & _ "Accepted by" & @CRLF & _ "Chairman, Departmental Committee" & @CRLF & _ "on Graduate Students" & @CRLF & _ "MASS. INST.TECH " & @CRLF & _ "SEP 29 1970" & @CRLF & _ "LIBRARIES" & @CRLF & _ "------------------------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "AIR RIGHTS DEVELOPMENT OF URBAN TRANSIT CORRIDORS" & @CRLF & _ "by" & @CRLF & _ "Steven C. Hayes" & @CRLF & _ "B.S. BOSTON UNIVERSITY" & @CRLF & _ "1971" & @CRLF & _ "Submitted in partial fulfillment of" & @CRLF & _ "the requirements for the" & @CRLF & _ "Degree of Master of Architecture" & @CRLF & _ "at the" & @CRLF & _ "MASSACHUSETTS INSTITUTE OF TECHNOLOGY" & @CRLF & _ "January, 1975" & @CRLF & _ "Author" & @CRLF & _ "Department of Architecture, Janurary 22, 1975" & @CRLF & _ "Certified by" & @CRLF & _ "Thesis Supervisor" & @CRLF & _ "Accepted by" & @CRLF & _ "Chairman, Departmental Committee on Graduate Students" & @CRLF & _ "Archives" & @CRLF & _ "MASS.INST. TECH." & @CRLF & _ "FEB 13 1975" & @CRLF & _ "LIBRARIES" & @CRLF & _ "--------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "BUILDINGS AS SYS TEMS" & @CRLF & _ "by" & @CRLF & _ "Ary M. Pedju" & @CRLF & _ "Ir. Ars., Institut Teknologi Bandung," & @CRLF & _ "Bandung, Indonesia, 1963" & @CRLF & _ "Submitted in partial fulfillment of the" & @CRLF & _ "requirements for the degree of Master in" & @CRLF & _ "Architecture at the Massachusetts Institute" & @CRLF & _ "of Technology, June 1965." & @CRLF & _ "Submitted by" & @CRLF & _ "Ary M. Pedju" & @CRLF & _ "Certified by" & @CRLF & _ "Eduardo F. Catalano" & @CRLF & _ "Thesis Advisor" & @CRLF & _ "Accepted by" & @CRLF & _ "Lawrence B. Anderson" & @CRLF & _ "Head, Department of Architecture" & @CRLF & _ "----------------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "PROCEDURES AS A PEPPESFNTATICN FOR DATA" & @CRLF & _ "IN A COMPUTER PROGRAM FOR UNDERSTANDING" & @CRLF & _ "NATURAL LANGUAGE" & @CRLF & _ "by" & @CRLF & _ "Terry Winograd" & @CRLF & _ "P.A., The Colorado College" & @CRLF & _ "(1966)" & @CRLF & _ "SUBMITTED IN PARTIAL FULFILLMENT" & @CRLF & _ "OF THE REQUIREMENTS FOR THE" & @CRLF & _ "DEGREE OF DOCTOR OF" & @CRLF & _ "PHILOSOPHY" & @CRLF & _ "at the" & @CRLF & _ "MASSACHUSETTS INSTITUTE OF" & @CRLF & _ "TECHNOLOGY" & @CRLF & _ "August, 1970" & @CRLF & _ "Signature of Author" & @CRLF & _ "Department of Mathematics August 24, 1970" & @CRLF & _ "Certified by" & @CRLF & _ "Thesis Supervisor" & @CRLF & _ "Accepted by" & @CRLF & _ "Chairman, Departmental Committee" & @CRLF & _ "on Graduate Students" & @CRLF & _ "MASS. INST.TECH " & @CRLF & _ "SEP 29 1970" & @CRLF & _ "LIBRARIES" & @CRLF & _ "---------------------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "STALL PROPAGATION IN AXIAL COMPRESSORS" & @CRLF & _ "ALAN H. STENNING" & @CRLF & _ "B.Sc., University of Glasgow" & @CRLF & _ "(1950)" & @CRLF & _ "S.M., Massachusetts Institute of Technology" & @CRLF & _ "(1951)" & @CRLF & _ "SUBMITTED IN PARTIAL FULFILLMENT" & @CRLF & _ "OF THE REQUIREMENTS FOR THE" & @CRLF & _ "DEGREE OF DOCTOR OF SCIENCE" & @CRLF & _ "at the" & @CRLF & _ "MASSACHUSETTS INSTITUTE OF TECHNOLOGY" & @CRLF & _ "June, 1955" & @CRLF & _ "Signature of Author" & @CRLF & _ "Department of Mechanical Engineering, May 10, 1955" & @CRLF & _ "Certified by" & @CRLF & _ "Thesis Supervisor" & @CRLF & _ "Accepted by" & @CRLF & _ "Chairman, Departmental Committee on Graduate Students" & @CRLF & _ "------------------------------------------------------------------------------" & @CRLF & _ "A HEADQUARTERS FOR THE WORLD HEALTH ORGANIZATION" & @CRLF & _ "IN GENEVA, SWITZERLAND" & @CRLF & _ "by" & @CRLF & _ "Johannes Philipp Holschneider" & @CRLF & _ "Diplom Ingenieur, 1959" & @CRLF & _ "Technische Hochschule" & @CRLF & _ "Karlsruhe/Rhein, Germany" & @CRLF & _ "SUBMITTED IN PARTIAL FULFILLMENT OF" & @CRLF & _ "THE REQUIREMENTS FOR THE DEGREE" & @CRLF & _ "OF MASTER IN ARCHITECTURE at the" & @CRLF & _ "MASSACHUSETTS INSTITUTE OF TECHNOLOGY" & @CRLF & _ "Signature of Author" & @CRLF & _ "Certified by" & @CRLF & _ "A Thesis Supervisor" & @CRLF & _ "Accepted by" & @CRLF & _ "Chairman, Departmental Committee" & @CRLF & _ "on Graduate Students" & @CRLF & _ "----------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "AN INVESTIGATION OF THE POWER SPECTRAL DENSITY OF ATMOSPHERIC TURBULENCE" & @CRLF & _ "by" & @CRLF & _ "GERHARDT C. CLEMENTSON" & @CRLF & _ "B.S. U.S. Military Academy, 1942" & @CRLF & _ "M.S. California Institute of Technology, 1945" & @CRLF & _ "S.M. Massachusetts Institute of Technology, 1948" & @CRLF & _ "SUBMITTED IN PARTIAL FULFILLMENT OF THE" & @CRLF & _ "REQUIREMENTS FOR THE DEGREE OF" & @CRLF & _ "DOCTOR OF SCIENCE" & @CRLF & _ "at" & @CRLF & _ "MASSACHUSETTS INSTITUTE OF TECHNOLOGY" & @CRLF & _ "1950" & @CRLF & _ "Signature of Author" & @CRLF & _ "Thesis Supervisor" & @CRLF & _ "Chairman, Departmental Committee on Graduate Students" & @CRLF & _ "------------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "OXIDATION STUDIES" & @CRLF & _ "IN" & @CRLF & _ "METAL-CARBON SYSTEMS" & @CRLF & _ "by" & @CRLF & _ "Watt Wetmore Webb" & @CRLF & _ "S.B. Massachusetts Institute of Technology 1947" & @CRLF & _ "Submitted in Partial Fulfillment of the" & @CRLF & _ "Requirements for the Degree of" & @CRLF & _ "Doctor of Science" & @CRLF & _ "from the" & @CRLF & _ "Massachusetts Institute of Technology" & @CRLF & _ "1955" & @CRLF & _ "Signature of Author" & @CRLF & _ "Department of Metallurgy" & @CRLF & _ "May 16, 1955" & @CRLF & _ "Professors in Charge of Research" & @CRLF & _ "Chairman, Departmental Committee" & @CRLF & _ "on Graduate Students" & @CRLF & _ "-------------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "NEW YWCA BUILDING," & @CRLF & _ "PITTSBURGH, PA." & @CRLF & _ "A thesis is submitted in partial fulfillment of the requirements" & @CRLF & _ "for the degree of Master in Architecture at Massachusetts " & @CRLF & _ "Institute of Technology" & @CRLF & _ "Submitted by" & @CRLF & _ "Visvaldis Paukulis" & @CRLF & _ "B.Arch., State Inst. of" & @CRLF & _ "Technology, Riga, Latvia" & @CRLF & _ "To" & @CRLF & _ "Lawrence B. Anderson" & @CRLF & _ "Head, Department of Architecture, M.I.T." & @CRLF & _ "-------------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "THE CORROSION OF STEEL IN SALINE" & @CRLF & _ "SOLUTIONS OF HYDROGEN SULFIDE" & @CRLF & _ "by" & @CRLF & _ "SANFORD J. NEUHAUS" & @CRLF & _ "Submitted in Partial Fulfillment of the" & @CRLF & _ "Requirements for the S.B. Degree" & @CRLF & _ "from the" & @CRLF & _ "MASSACHUSETTS INSTITUTE OF TECHNOLOGY" & @CRLF & _ "1945" & @CRLF & _ "Signature of Author" & @CRLF & _ "Department of Chemical Engineering, June, 1945" & @CRLF & _ "Signature or Thesis Supervisor" & @CRLF & _ "-----------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "THE CHROMIUM-OXYGEN-HYDROGEN EQUILIBRIUM IN LIQUID IRON" & @CRLF & _ "by" & @CRLF & _ "HSIN-MIN CHEN" & @CRLF & _ "B. S., National Tsinghua University" & @CRLF & _ "1935" & @CRLF & _ "Submitted in Partial Fulfillment of the" & @CRLF & _ "Requirements for the Degree of" & @CRLF & _ "DOCTOR OF SCIENCE" & @CRLF & _ "from the" & @CRLF & _ "Massachusetts Institute of Technology" & @CRLF & _ "1945" & @CRLF & _ "Signature of Author" & @CRLF & _ "Department of Metallurgy" & @CRLF & _ "June 4, 1945 " & @CRLF & _ "Signature of Professor" & @CRLF & _ "in Charge of Research " & @CRLF & _ "Signature of Chairman" & @CRLF & _ "Department Committee" & @CRLF & _ "on Graduate Students" & @CRLF & _ "--------------------------------------------------------------" & @CRLF & _ "MIT Sample:" & @CRLF & _ "A CRITICAL SURVEY OF PUBLISHED" & @CRLF & _ "PHYSICAL PLANNING PRINCIPLES" & @CRLF & _ "by" & @CRLF & _ "Thomas A. Reiner" & @CRLF & _ "B.A., Swarthmore College" & @CRLF & _ "(1952)" & @CRLF & _ "Submitted in partial fulfillment of the requirements" & @CRLF & _ "for the degree of Master in City Planning" & @CRLF & _ "at the" & @CRLF & _ "Massachusetts Institute of Technology" & @CRLF & _ "(May 1955)" & @CRLF & _ "Head, Department of City and Regional Planning" & @CRLF & _ "Thesis Advisor" & @CRLF & _ "Author" & @CRLF & _ "----------------------------------------------------------------------" & @CRLF & _ "Virginia Tech Sample:" & @CRLF & _ "THEY EXPERIENCE OF THE CATHOLIC DIOCESE OF RICHMOND" & @CRLF & _ "WITH ESEA TITLE I, APRIL 1965 -- DECEMBER 1976" & @CRLF & _ "by" & @CRLF & _ "Richard J.Fenchak " & @CRLF & _ "Dissertation submitted to the faculty of" & @CRLF & _ "Virginia Polytechnic Institute and State University" & @CRLF & _ "in partial fulfillment of the requirements for the degree of" & @CRLF & _ "DOCTOR OF EDUCATION" & @CRLF & _ "in" & @CRLF & _ "Educational Administration" & @CRLF & _ "APPROVED:" & @CRLF & _ "David J. Parks (Co-Chair) Thomas C. Hunt (Co-Chair)" & @CRLF & _ "M. David Alexander James W. Michaels" & @CRLF & _ "Kenneth E. Underwood" & @CRLF & _ "January, 1986" & @CRLF & _ "Blacksburg, Virginia" & @CRLF & _ "----------------------------------------------------" & @CRLF & _ "Virginia Tech Sample:" & @CRLF & _ "ASSESSMENT OF A MENTOR PROGRAM" & @CRLF & _ "ON SELF-CONCEPT AND ACHIEVEMENT VARIABLES" & @CRLF & _ "OF MIDDLE SCHOOL UNDERACHIEVERS" & @CRLF & _ "by" & @CRLF & _ "Helene Aiello" & @CRLF & _ "Dissertation submitted to the faculty of the Virginia" & @CRLF & _ "Polytechnic Institute and State University in partial" & @CRLF & _ "fulfillment of the requirements for the degree of" & @CRLF & _ "Doctor of Education" & @CRLF & _ "in" & @CRLF & _ "Administration and Supervision" & @CRLF & _ "Of" & @CRLF & _ "Special Education" & @CRLF & _ "APPROVED:" & @CRLF & _ "Philip R. Jones, Chairman Kenneth Underwood" & @CRLF & _ "Sylvia Auton" & @CRLF & _ "Shirley Jones Ronald McKeen" & @CRLF & _ "February 22, 1988" & @CRLF & _ "Blacksburg, Virginia" & @CRLF & _ "---------------------------------------------------" & @CRLF & _ "Virginia Tech Sample:" & @CRLF & _ "Synthesis, Characterization and Kinetic Investigations of Heterophase Materials" & @CRLF & _ "Prepared Using Group Transfer Polymerization" & @CRLF & _ "by" & @CRLF & _ "Ann Marie Hellstern" & @CRLF & _ "Dissertation submitted to the faculty of the Virginia Polytechnic Institute and" & @CRLF & _ "State University in partial fulfillment of the requirements for the degree of" & @CRLF & _ "Doctor of Philosophy" & @CRLF & _ "in" & @CRLF & _ "Chemistry" & @CRLF & _ "Approved By:" & @CRLF & _ "J.E. McGrath" & @CRLF & _ "G. L. Wilkes J. F. Wolfe" & @CRLF & _ "B.E. Hanson H.M. Bell" & @CRLF & _ "-----------------------------------------------------------" & @CRLF & _ "Virginia Tech Sample:" & @CRLF & _ "THE KINETICS AND THERMODYNAMICS" & @CRLF & _ "OF CLAY MINERAL REACTIONS" & @CRLF & _ "by" & @CRLF & _ "John Alan Chermak" & @CRLF & _ "Dissertation submitted to the faculty of" & @CRLF & _ "Virginia Polytechnic Institute and State University" & @CRLF & _ "in partial fulfillment of the requirements of the degree of" & @CRLF & _ "DOCTOR OF PHILOSOPHY" & @CRLF & _ "In" & @CRLF & _ "Geology" & @CRLF & _ "APPROVED:" & @CRLF & _ "J. D. Rimstidt, Chairman" & @CRLF & _ "L. W. Zelazny J. R. Craig" & @CRLF & _ "R. J. Bodnar S. C. Eriksson" & @CRLF & _ "November, 1989" & @CRLF & _ "Blacksburg, Virginia" & @CRLF & _ "-------------------------------------------------------------" & @CRLF & _ "Virginia Tech Sample:" & @CRLF & _ "STRATEGIES AND TACTICS TO ACCESS INTUITION:" & @CRLF & _ "A LOOK AT THE MOMENT OF SOLUTION" & @CRLF & _ "by" & @CRLF & _ "Linda E. Morris" & @CRLF & _ "Dissertation submitted to the faculty of the" & @CRLF & _ "Virginia Polytechnic Institute and State University" & @CRLF & _ "in partial fulfillment of the requirements for the degree of" & @CRLF & _ "DOCTOR OF EDUCATION" & @CRLF & _ "Adult Continuing Education" & @CRLF & _ "Approved:" & @CRLF & _ "Dr. Marcie Boucouvalas, Chairperson" & @CRLF & _ "Dr. Neal E. Chalofsky Dr. Hugo A. Keesing" & @CRLF & _ "Dr. Ronald L. McKeen Dr. Orion F. White" & @CRLF & _ "March 1, 1990" & @CRLF & _ "Blacksburg, Virginia" & @CRLF & _ "----------------------------------------------------------" & @CRLF & _ "Virginia Tech Sample:" & @CRLF & _ "PREDICTION MODEL FOR THE ONSET OF EDGE-EFFECT DELAMINATION" & @CRLF & _ "at holes in composite laminates" & @CRLF & _ "by" & @CRLF & _ "Doron Shalev" & @CRLF & _ "Dissertation submitted to the faculty of the" & @CRLF & _ "Virginia Polytechnic Institute and State University" & @CRLF & _ "in partial fulfillment of the requirements for the degree of" & @CRLF & _ "DOCTOR OF PHILOSOPHY" & @CRLF & _ "in" & @CRLF & _ "Engineering Science and Mechanics" & @CRLF & _ "APPROVED:" & @CRLF & _ "K. L. Reifsnider" & @CRLF & _ "C. W. Smith R. T. Haftka" & @CRLF & _ "R. M. Jones R. A. Heller" & @CRLF & _ "July, 1988" & @CRLF & _ "Blacksburg, Virginia" 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