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

r"
"

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"Marca[s]{0,}[:]{0,}[.]{0,}[ ]{0,}[A-Z]{3,}[ ]{0,}[A-Z]{0,}[ ]{0,}[A-Z]{0,}"; string input = @"RESUMEN DE AUTOMÓVILES RESIDENTES Número de Póliza: 0003098447 Vigencia Desde: 12:00 Hrs. 02/12/2020 Hasta: 12:00 Hrs. 02/12/2021 Fecha de Emisión: 12:00 Hrs. 02/12/2020 DATOS DEL CONTRATANTE Nombre: AYALA MARTINEZ, JOSE RFC.: AAMJ4410183W0 Domicilio: ANDADOR 17, DPTO. ENTRADA B. RESIDENCIAL ACUEDUCTO C.P.: 7270 DE GUADA. GUSTAVO A. MADERO. CDMX DATOS DE LA PÓLIZA Línea: AUTOMÓVILES RESIDENTES Unidades A Riesgo: 1 Prima: $4,000.00 Clave Agente: 95099 Prima Neta: $2,513.45 Nombre: BAJA TU SEGURO AGENTE DE SEGUROS S.A. DE C.V. Financiamiento: $0.00 Forma de pago: ANUAL Gastos de Expedición: $590.00 Moneda: Pesos Gastos de expedición $ 400,00 Exentos de IVA: I.V.A.: $496.55 Prima Total: $4,000.00 Monterrey (81) 8318 3874 En caso de Siniestro, se puede reportar a través de nuestra App O llame Ciudad de México (55) 5140 3050 Disponible para iOS y Android Cualquier Parte de la 800 723 4763 República Mexicana SEGUROS AFIRME S.A. DE C.V., AFIRME GRUPO FINANCIERO (en lo sucesivo la ""Institución""), asegura a favor de la persona arriba citada (en lo sucesivo el ""Asegurado"") el vehículo descrito en la presente Carátula, contra los riesgos descritos más adelante y durante la vigencia establecida, sujeto a las condiciones generales y en su caso particulares entregadas junto con esta Carátula. En cumplimiento a lo dispuesto en el artículo 202 de la ley de instituciones de seguros y fianzas, la documentación contractual y la nota técnica que integran este producto, quedaron registradas ante la comisión nacional de seguros y fianzas, a partir del día 19 de diciembre de 2018, con el número: CNSF-S0094-0685-2018 En testimonio de lo cual SEGUROS AFIRME, S.A. de C.V., AFIRME GRUPO FINANCIERO, Firma la presente forma en Monterrey Nuevo León, México Página: 1CARATULA DE AUTOMÓVILES RESIDENTES Número de Póliza: 0003098447Inciso: 000 Vigencia desde: 12:00 HRS. 02/12/2020 Hasta: 12:00 HRS. 02/12/2021 Fecha de Emisión 12:00 HRS. 02/12/2020 DATOS DEL ASEGURADO Nombre: AYALA MARTINEZ, JOSE Domicilio: ANDADOR 17, DPTO. ENTRADA B. RESIDENCIAL R.F.C.: AAMJ4410183W0 ACUEDUCTO DE GUADA. GUSTAVO A. MADERO. CDMX Contratante: AYALA MARTINEZ, JOSE C.P.: 7270 Conductor: AYALA MARTINEZ, JOSE DATOS DEL VEHÍCULO Marca: CHEVROLET Modelo: 2018 Tipo: AUTOMÓVILES Versión: CHEVROLET AVEO 1.5 LS PAQ A TM Número de Serie: LSGHD52HXJD152678 5 Placas: W17AWP Pasajeros: Número de Motor: HECHO EN CHINA Uso: PARTICULAR Clave: 1006005601 Tipo de carga: COBERTURAS LÍMITE MÁXIMO DE DEDUCIBLE PRIMA RESPONSABILIDAD DAÑOS MATERIALES VALOR COMERCIAL +10 5 % $ 218,58 ROBO TOTAL VALOR COMERCIAL +10 10 % $ 84,60 RESPONSABILIDAD CIVIL LUC $ 2.500.000,00 $ 499,72 GASTOS MÉDICOS OCUPANTES $ 500.000,00 $ 148,95 ASISTENCIA JURÍDICA AMPARADA $ 200,00 ASISTENCIA VIAL AMPARADA $ 250,00 RESPONSABILIDAD CIVIL EN USA Y CANADÁ AMPARADA $ 0,00 AUTO SIGUE AFIRME AMPARADA $ 550,00 RESPONSABILIDAD CIVIL EN EXCESO POR MUERTE $ 3.000.000,00 $ 167,81 EXENCIÓN DE DEDUCIBLES PERDIDA TOTAL DAÑOS MATERIALES AMPARADA $ 11,16 EXENCIÓN DE DEDUCIBLES POR ROBO TOTAL AMPARADA $ 8,46 EXTENSIÓN DE RESPONSABILIDAD CIVIL CONDUCTOR HABITUAL $ 2.500.000,00 $ 74,96 ACCIDENTES AUTOMOVILÍSTICOS AL CONDUCTOR $ 100.000,00 $ 33,24 AUTO AGENCIA AMPARADA $ 105,01 ROBO PARCIAL AMPARADA $ 160,95 Pagina: 1"; Match m = Regex.Match(input, pattern); 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