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

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