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

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