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

/
/
mgD

Test String

Code Generator

Generated Code

$re = '/^(?P<series>[(][^_-]+?[)])?[\s]*(?P<author>(?! [-]).*?)([\s]+?-[\s]*)(?P<title>[^\(]*?)(?P<titletail>[\s]*?)((?P<comments>[\(](?:[\s]*(((?P<published>[12][\d]{3,3})\s*)((?=([,\)]))))?)?((?P<prepublisher>[\w]*?[,-]?)([,]?[\s]*((?P<publisher>[-|~\'&%$#"!\w\s]*(([a-zA-Z]+)[-|~\'&%$#"!\w\s]*))(?!(([\d-]{11}-?([x]|[\d])[\s]*[\)])))))?(?P<isbn>([,]?[\s]*(?P<isbntag>(?i)ISBN[-]?1(?:(?P<is10>0)|3)?[:\s])?\s*(?(isbntag)(?(is10)((?=[\d-]{11}-[\d|x][\s]*[\)])(?P<isbn10>\d{1,5}[ -]\d{1,7}[ -]\d{1,6}[ -](?:\d|x)))|((?:(?=[\d-]{17}[\s]*[\)])(?P<isbn13>97(?:8|9)[ -]\d{1,5}[ -]\d{1,7}[ -]\d{1,6}[ -]\d))))|(?:(?=(([\d-]{11}-([\d]|[x]))[\s]*[\)]))(?P<ISBN10>\d{1,5}([ -])\d{1,7}[ -]\d{1,6}[ -](?:\d|x))|(?:(?=[\d-]{17}[\s]*[\)])(?P<ISBN13>97(?:8|9)[ -]\d{1,5}[ -]\d{1,7}[ -]\d{1,6}[ -]\d)))))?)(?=([\s]*[,\)])))?(?P<tooManyCommasOrOnlyDigits>.*)[\s]*[\)]))*?[.](?P<extension>[[:alpha:]]+)$/mD'; $str = '(Graduate Texts in Mathematics 228) Fred Diamond, Jerry Shurman (auth.) - A First Course in Modular Forms - Springer-Verlag New York (2005).pdf Antonio Martinez-Abe--jón - Correct Antidifferentiation_ The Change Of Variable Well Done - World Scientific (2020).pdf (Lecture Notes in Mathematics) Peter G. Casazza, Thaddeus J. Shura, J Baker, O. Slotterbeck, R. Aron - Tsirelsons Space-Springer (1989).djvu Antonio Martinez-Abejón - Correct Antidifferentiation_ The Change Of Variable Well Done - World Scientific (2020).pdf Junji Ito - The Enigma of Amigara Fault.pdf Junji Ito - The Enigma of Amigara Fault(.pdf Junji Ito - The Enigma of Amigara Fault().pdf [series ] author - this is it (1234, 345-801-028-x).epub [series ] author - this is it (1234, 345-801-028-8).epub [series ] author - this is it (1234, 345-801-028-x).epub [series ] author - this is it (1234, 345-801-028-8).epub author, et6wl - this fsis it (123h4 , ISBN-13: 978-801-028-060-7 ).epub [serie0\'0\'&%\'&%$&%$#"$"!s ] author, au-thor !"#$%&\'=~| - this!""#$%&\'=~|¥¥¥¥¥¥--[[[[]]]:: is it (1234, publish , 345-801-028-x ).epub [serie ] author, author - this is it (1234, publish ,ISBN-10: 345-801-028-x ).epub [serie ] author, author - this is it (1234, publish ,ISBN-10: 345-801-028-x ).epub [series ] author - this is it (1234, 345-801-028-8).epub [series ] author - this is it (1234, 345-801-028-x).epub [series ] author - this it (1234,ddddd 345-801-028-8).epub [series ] author - this is it (1234, 345-801-028-8).epub [series ] author - this is it (9234, 345-801-028-x).epub [series ]author - this is it (1234, 978-801-028-060-7).epub [series ]author - this is it (123, 1234erw978-8888801-028-060-7).epub [series ]author - this is it (978-801-028-060-7).epub [series ]author - this is it (78-801-0260-7).epub [series ]author - not enough dashes (78-80-150260-7).epub [series ]author - this is it (12343-p978-801-0260-7).epub [series ]author - this is it (g123,978-801-028-060-7).epub [series ]author - this is it (1234-lk-jkj978-801-028-060-7).epub [series ]author - this is it (1234,lkjkj978-801-028-060-7).epub [series ]author - this is it (123,4lkjkj,978-801-028-060-7).epub [series ]author - this is it (1234,jhkh987\'&%\'%$#$%&ljh,lkjnkjnlkjhljh 5545t , 978-801-028-060-7).epub (,1234) [series ]author - this is it (,ISBN-13: 978-801-028-060-7).epub [series ]author - this is it (1234,ISBN-10: 978-801-006-0).epub [series ]author - this is it (1234,ISBN-13: 978-801-028-060-7).epub [series ]author - this is it (,ISBN-10: 978-801-006-x).epub [series ]author - this is it (ISBN-10: 978-801-006-x).epub (Graduate Texts in Mathematics) Daniel W. Stroock - Essentials of Integration Theory for Analysis-Springer (2020).pdf (Graduate Texts in Mathematics 3) Helmut H. Schaefer (auth.) - Topological Vector Spaces-Springer New York (1971).pdf (Pure and Applied Mathematics) Lawrence Narici, Edward Beckenstein - Topological Vector Spaces-Chapman and Hall_CRC (2011).djvu (Lecture Notes in Mathematics) L. Bernstein - The Jacobi-Perron Algorithm Its Theory and Application-Springer (1971).djvu (Memoirs AMS 85) Donald W. Solomon - Denjoy Integration in Abstract Spaces-Amer Mathematical Society (1969).djvu (Springer Series in Statistics) Shelby J. Haberman (auth.) - Advanced Statistics_ Description of Populations-Springer-Verlag New York (1996).pdf (Graduate Studies in Mathematics, Vol.4) Russell A. Gordon - The Integrals of Lebesgue, Denjoy, Perron, and Henstock-American Mathematical Society (1994).pdf (Springer Series in Statistics) Per Kragh Andersen, Ørnulf Borgan, Richard D. Gill, Niels Keiding (auth.) - Statistical Models Based on Counting Processes-Springer-Verlag New York (1993).pdf (Mathematical Surveys and Monographs 007-2) A. H. Clifford - The algebraic theory of semigroups. Vol.2-American Mathematical Society (1967).djvu (History of Mathematics) Christopher Hollings - Mathematics Across the Iron Curtain_ A History of the Algebraic Theory of Semigroups-American Mathematical Society (2014).pdf (Undergraduate Lecture Notes in Physics) Bruce Cameron Reed - The History and Science of the Manhattan Project, 2nd ed.-Springer (2019).pdf Bruce Cameron Reed - The Physics of the Manhattan Project-Springer (2014).pdf Junji Ito - The Enigma of Amigara Fault.pdf (Lecture Notes in Mathematics) Peter G Casazza Thaddeus J Shura J Baker O Slotterbeck R Aron - Tsirelsons Space-Springer (1989).djvu IKEI SEKAI.cbz Yami no Koe (notitle).cbr uzumaki-3vols notitle.zip (Lecture Notes in Mathematics) Peter G Casazza Thaddeus J Shura J Baker O Slotterbeck R Aron - Tsirelsons Space-Springer (1989).djvu Mark F. Sanders, John L. Bowman - Genetic Analysis_ An Integrated Approach-Pearson Education (2014).pdf Rey Chow, Paul Bowman - The Rey Chow Reader-Columbia University Press (2010).epub ([sic], 7) Sebastian Budgen, Stathis Kouvelakis, Slavoj Zizek, David Fernbach - Lenin Reloaded_ Toward a Politics of Truth-Duke University Press Books (2007).pdf Paul Bowman, Richard Stamp - The Truth of Zizek-Bloomsbury Academic (2007).pdf John Stewart Bowman - Columbia chronologies of Asian history and culture-Columbia University Press (2000).pdf Constance Bowman Reid - Slacks and Calluses_ Our Summer in a Bomber Factory-Smithsonian Books (2004).epub Shawn Gascoyne-Bowman - Criminal Crafts_ From D.I.Y. to F.B.I. Outlaw Projects for Scoundrels, Cheats, and Armchair Detectives-Andrews McMeel Publishing (2012).epub Maurice Isserman, John S. Bowman - Vietnam War (America at War) (2003).pdf Sharon L. Bowman - Training From the Back of the Room!_ 65 Ways to Step Aside and Let Them Learn (2008).pdf Gary Bowman - Essential Quantum Mechanics-Oxford University Press, USA (2008).pdf (Statistics, textbooks and monographs 103) K. O. Bowman, L. R. Shenton - Continued fractions in statistical applications-M. Dekker (1989).djvu Frank Bowman - Introduction to Bessel Functions-Dover Publications (2010).djvu E. Hille, R. Phillips - Functional Analysis and Semi-Groups.pdf Einar Hille - Functional Analysis And Semi-Groups-Dutt Press (2007).djvu Prof. Dr. Heinz-Otto Peitgen, Prof. Dr. Peter H. Richter (auth.) - The Beauty of Fractals_ Images of Complex Dynamical Systems-Springer-Verlag Berlin Heidelberg (1986).pdf 09notitle.pdf 9502219 (1).pdf 020707798 dddd-- -.pdf (Universitext_ Tracts in Mathematics) Lennart Carleson, Theodore W. Gamelin (auth.) - Complex Dynamics-Springer-Verlag New York (1993).pdf Charles Jordan - Calculus of Finite Differences (AMS Chelsea Publishing)-American Mathematical Society (1950).pdf Robert Ghrist - Calculus BLUE Multivariable Vol 4_ Fields (2018).pdf Robert Ghrist - Elementary Applied Topology-CreateSpace Independent Publishing Platform (2014).pdf (Series on Advances in Mathematics for Applied Sciences) Bellomo N. (ed.) - Lecture Notes on Mathematical Theory of the Boltzmann Equation-World Scientific (1995).djvu 9502219.pdf 2b597b0c2f8fe191982391986140cbb462ea.pdf rm8370.pdf (Cambridge Library Collection - Mathematics) George Boole - A Treatise on the Calculus of Finite Differences-Cambridge University Press (2009).pdf (Mathematics in Science and Engineering 19) J. Aczpl (Eds.) - Lectures on Functional Equations their and Applications-Elsevier, Academic Press (1966).pdf ᾠA. A. Bolibruch, Yu. S. Osipov, Ya. G. Sinai, V. I. Arnold, A. A. Bolibruch, A. M. Vershik, Yu. I. Manin, Yu. S. Osipov, Ya.G. Sinai, V.M. Tikhomirov, L.D. Faddeev, V. B. Philippov (eds.) - Mathemati.pdf (London Mathematical Society Student Texts) Jonathan R. Partington - Linear Operators and Linear Systems_ An Analytical Approach to Control Theory-Cambridge University Press (2004).pdf Ib Henning Madsen, Jørgen Tornehave - From calculus to cohomology_ de Rham cohomology and characteristic classes-Cambridge University Press (1997).pdf (Universitext) Dr. Shiing-shen Chern (auth.) - Complex Manifolds without Potential Theory_ with an appendix on the geometry of characterist Jean Meeus - Astronomical Algorithms-Willmann-Bell (1998).pdf Stern - Anyons and the qauantum Hall Effect A Pedagogical reviewarovas_Stern_2007.pdf William C. Reynolds, Piero Colonna - Thermodynamics_ Fundamentals and engineering applications-Cambridge University Press (2018).pdf Barry B. Luokkala - Exploring Science Through Science Fiction-Not Avail (2014).epub (BTEC 2016) Jennifer Stafford-Brown, Simon Rea, Tim Eldridge - BTEC National Level 3 Sport and Exercise Science 4th Edition-Hodder Education (2016).epub John Dirk Walecka - Introduction to Electricity and Magnetism-World Scientific Publishing Company (2018).pdf William R. Gibbs - Computation In Modern Physics-World Scientific Publishing Co Pte Ltd (2006).pdf I. T Todorov - Analytic properties of Feynman diagrams in quantum field theory -Pergamon (1971).djvu Duncan Carlsmith - Particle Physics-Pearson (2013).pdf HSP - Mississippi Science, Grade 1 - Interactive Student Edition-Houghton Mifflin Harcourt (HMH) (2007).pdf (1) James S. Walker - Pearson Physics. 1-Pearson Education (2013).pdf Duncan Carlsmith - Particle Physics-Pearson (2013) copy.pdf Abraham Seiden - Particle Physics A Comprehensive Introduction-Pearson Addison Wesley (2005).pdf Brian Arnold_ Steve Woolley_ Penny Johnson - Edexcel International GCSE (9-1) Physics Student Book-Pearson Education Limited (2017).pdf James E. Ackroyd, Mark Anderson, Carmen Berg, Brian E. Martin - Pearson Physics – Student Edition (2009).pdf HSP - Mississippi Science, Grade 2 - Interactive (Write-in) Student Edition-Houghton Mifflin Harcourt (HMH) (2007).pdf Free HIgh School Science Texts.pdf Firk - Introduction to Groups, Invariants and Particles.pdf Paul W. Zitzewitz, T. G. Elliott, Haase, Kathleen A. Harper, Herzog, Nelson, Friedrich Schiller, Zorn - Physics. Principles and Problems [textbook]-McGraw-Hill_Glencoe (2004).pdf J. P. Elliott, P. G. Dawber (auth.) - Symmetry in Physics_ Volume 1_ Principles and Simple Applications-Macmillan Education UK (1979).pdf (Lecture Notes in Physics 732) Franco Strocchi (auth.) - Symmetry Breaking-Springer-Verlag Berlin Heidelberg (2008).pdf Robinson, Matthew B - Symmetry and the standard model_ Mathematics and particle physics-Springer (2011).pdf J. P. Elliott, P. G. Dawber (auth.) - Symmetry in Physics_ Further Applications-Macmillan Education UK (1979).pdf 10.1038@s41567-019-0748-5.pdf (Mathematics and Its Applications 290) Geoffrey M. Dixon (auth.) - Division Algebras_ Octonions, Quaternions, Complex Numbers and the Algebraic Design of Physics-Springer US (1994).pdf (NATO ASI Series 352) Murray Gell-Mann (auth.), Harvey B. Newman, Thomas Ypsilantis (eds.) - History of Original Ideas and Basic Discoveries in Particle Physics-Springer US (1996).pdf Mann, Robert - An Introduction to Particle Physics and the Standard Model-CRC Press (2009).pdf Mark Thomson - Modern Particle Physics Student Solutions Manual-Cambridge University Press (2013).pdf B.H. Bransden, C.J. Joachain - Physics of Atoms and Molecules-Longman Publishing Group (1982).djvu Bransden B., Joachain C. - Quantum Mechanics (2000, Pearson).djvu Bransden B H. - Atomic Collision Theory-W A Benjamin Inc (1970).djvu Fermi E. - Nuclear Physics-University Of Chicago Press (1974).djvu (Midway reprints) Jay Orear_ Enrico Fermi_ Arthur H Rosenfeld_ Robert A Schluter - Nuclear physics _ a course given by Enrico Fermi at the University of Chicago-University of Chicago Press (1974).djvu Dr. John M. Marzluff, Mr. Tony Angell - In the Company of Crows and Ravens (2007).pdf Misha Shifman - Felix berezin_ life and death of the mastermind of supermathematics-Wspc (2007).pdf M Shifman (ed.) - Physics in a Mad World. Houtermans, Golfand-World Scientific (2015).epub Anthony Duncan - The Conceptual Framework of Quantum Field Theory (2012, Oxford University Press, USA).pdf (Cambridge monographs on mathematical physics) Erick J Weinberg - Classical solutions in quantum field theory _ solitons and instantons in high energy physics-Cambridge University Press (2012).pdf Luc Steels_ Katrien Beuls - Case Studies in Fluid Construction Grammar_ The Verb Phrase-John Benjamins Publishing Company (2019).pdf (Palgrave Studies In Literature, Science And Medicine) Emily Alder - Weird Fiction And Science At The Fin De Siècle-Palgrave Macmillan (2020).pdf Anthony Duncan_ Michel Janssen - Constructing Quantum Mechanics_ Volume 1_ The Scaffold_ 1900-1923-Oxford University Press, USA (2019).pdf (The Frontiers Collection) Dean Rickles - A Brief History of String Theory_ From Dual Models to M-Theory-Springer (2014).pdf 0711_PRL99.pdf [Frontiers in Physics] Graham Ross - Grand Unified Theories (1984, Benjamin-Cummings Pub Co) (1).djvu 0911.0695.pdf Robert Botet, Marek Poszajczak, M. Ploszajczak - Universal fluctuations_ the phenomenology of hadronic matter-World Scientific Publishing Company (2002).pdf Book_Hadronic_Matter.pdf 11519879.pdf 0210054.pdf Standard_Model_Flowchart.pdf The Algebra of Grand Unified Theories John Baez and John Huerta.pdf The Algebra of Grand Unified Theories John Huerta.pdf '; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php