Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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 single character of: a, b, c or d
    [[ab][cd]]
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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
Processing...

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"^([a-zA-ZáéíóúàèìòùÁÉÍÓÚÀÈÌÒÙ]+ )*+[a-zA-ZáéíóúàèìòùÁÉÍÓÚÀÈÌÒÙ]+$"; string input = @"Aarón Ander Abel Andrés Joel Abelardo Ángel Jon Abraham Aníbal Jordi Adalberto Antonio Jorge Adam Arnau José Adán Arturo Jose Antonio Adiran Asier Jose Luis Adolfo Augusto Jose Manuel Adrià Aurelio Jose Maria Adrián Baltasar Juan Agustín Bartolomé Blas Aimar Basilio Juan Antonio Aitor Benito Boris Alano Benjamín Juan Carlos Alberto Bernardo Borja Aldo Bienvenido Brahim Aleix Blas Brais Alejandro Boris Bruno Alejo Borja Calisto Alex Brahim Juan José Alfonso Brais Camilo Alfredo Bruno Juan Manuel Alonso Calisto Carlos Álvaro Camilo Julio Amadeo Carlos Cayetano Amado Cayetano César Amando César Christian Ambrosio Christian Claudio Amin Claudio Clemente Anastasio Clemente Conrado Ander Conrado Constantino Constantino Francisco Javier Joel Crispín Francisco José Jon Cristian Gabriel Jordi Daniel Gaspar Jorge Darío Gerard José David Gerardo Jose Antonio Desiderio Germán Jose Luis Diego Gonzalo Jose Manuel Dionisio Gregorio Jose Maria Domingo Guillem Juan Donato Guillermo Juan Antonio Edgar Gustavo Juan Carlos Edmundo Hamza Juan José Eduardo Héctor Juan Manuel Elías Honorato Julio Eloy Hugo Justino Emilio Humberto Justo Eneko Ibai Kevin Enrique Ibrahim Kilian Eric Ignacio Leo Ernesto Iker Leopoldo Esteban Isidoro Lorenzo Eugenio Ismael Louis Eusebio Ivo Lucas Fabián Izan Luciano Federico Jaime Luis Felipe Jan Macario Félix Jaume Manuel Fermín Javier Marc Fernando Jesús Marcelo Fidel Joan Marco Francisco Joaquín Marcos Marcos Pau Tomás Mariano Pedro Ulises Mario Pelayo Unai Marti Plácido Urbano Martín Platón Valentín Mateo Pol Vicente Matías Ponce Víctor Mauricio Quintín Virgilio Maximiliano Rafael Walter Máximo Ramiro Wen Miguel Ramón Xabier Miguel Ángel Raúl Xavier Mikel Ricardo Ximen Mohamed Roberto Yerai Moisés Rodrigo Yeray Nabil Rogelio Yunes Narciso Román Yusef Nathan Rubén Zacarías Nicolás Salvador Zenon Noé Samuel Zoilo Octavio Santiago Oier Sebastián Omar Sergi Oriol Sergio Óscar Silvestre Pablo Simón Pancho Teodoro"; RegexOptions options = RegexOptions.Multiline; foreach (Match m in Regex.Matches(input, pattern, options)) { Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index); } } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx