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

/
/
gi

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 = "(?i)ORÇAMENTO Nº\s*\d{4}\/(?<id_operacao>\d+-\d)|Ano\sModelo:\s*(?<ano_fabr>\d{4})\/(?<ano_modelo>\d{4})(?:\s*.*){2}\nVeículo-Marca:\s*(?<ds_marca>.*?)-(?<ds_modelo>.*\s)|Data:\s(?<Data>\d{1,2}\/\d{1,2}\/\d{2,4})|Número.*sais\s*(?<prazo>\d{1,2})|E.1\s*(?<Volume_Financiado>(?:\d+\.\d+)*(?:,\d{1,2}))|F.6.*?E.4\)\s.*(?:\d+\.\d+)*,\d{1,2}(?<Volume_Financiado_IOF>(?:\d+\.\d+)*,\d{1,2})|\+\sC.1\s*(?<valor_bem>(?:\d+\.\d+)*(?:,\d{1,2}))|ENTRADA\s*C.1\s*(?<valor_entrada>(?:\d+\.\d+|\d+)*(?:,\d{1,2}))|% a.a.\s*(?:\d+\.\d+|\d{1,3})*(?:,\d{1,2})(?<iof_total>(?:\d+\.\d+|\d{1,3})*(?:,\d{1,2}))|B.9\s*(?:\d{1,3}\.\d{1,3},\d{2}|\d{1,3},\d{2})(?<valor_gravame>\d{1,3}\.\d{1,3},\d{2}|\d{1,3},\d{2})|HCE.*\)\s(?<Taxa_com_Imposto>\d+,\d+)|End.*o:\s*(?<Cliente>.*)(?:\s*.*){4}\n(?<CPF_CNPJ_Cliente>\d{3}\.\d{3}\.\d{3}-\d{2}|\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2})|Lojista:CNPJ:(?:\s*\.*)\n(?<Dealer_Group>.*)(?<Dealer>\d{3}\.\d{3}\.\d{3}\/\d{4}-\d{2})|financiadas\s*\n(?:\d,\d{2})(?<valor_tac>(?:\d{1,4}|\d{1,3}\.\d{1,3}),\d{2})|F.5\s*(?<Pmt>(?:\d{1,3}|\d{1,3}\.\d{1,3}),\d{2})|B.2\n(?:\d,\d{2})(?<vr_acessorios>(?:\d{1,3}|\d{1,3}\.\d{1,3}),\d{2})|Seguradora\nCNPJ(?:\s*.*){4}\nCNPJ:(?:\s*.*){1}\n(?<valor_seguro>(?:\d{1,3}|\d{1,3}\.\d{1,3}),\d{2})|F.4\s*\n(?<Taxa_sem_Imposto>\d+(?:,{0,1}\d{1,2}))" Local $sString = "" & @CRLF & _ "" & @CRLF & _ "ATENÇÃO: A efetiva contratação da operação de crédito, nestas condições, depende da autorização da instituição financeira responsável pelo presente orçamento." & @CRLF & _ "ORÇAMENTO Nº" & @CRLF & _ "2019/7312134-1" & @CRLF & _ "ORÇAMENTO DE OPERAÇÃO DE CRÉDITO DIRETO" & @CRLF & _ "AO CONSUMIDOR (CDC) - PRODUTOS" & @CRLF & _ "DADOS DE RESPONSABILIDADE DO CORRESPONDENTE (CONCESSIONÁRIA / REVENDA / LOJISTA)" & @CRLF & _ "INFORMAÇÕES GERAIS: DADOS DO CONSUMIDOR E DO VEÍCULOA" & @CRLF & _ "A.1" & @CRLF & _ "Nome do(a) Consumidor(a):CPF / CNPJ do(a) solicitante:" & @CRLF & _ "Endereço e telefone de contato:" & @CRLF & _ "DANIEL AKIRA WATANABE" & @CRLF & _ "AV PASCHOAL THOMEU, 2278 - ( 11 ) 25362534" & @CRLF & _ "398.183.638-33" & @CRLF & _ "A.2" & @CRLF & _ "Ano Modelo:" & @CRLF & _ "2019/2020" & @CRLF & _ "Cor:" & @CRLF & _ "PRATA" & @CRLF & _ "Veículo-Marca:" & @CRLF & _ "HONDA-CITY(N.GERAÇÃO) DX-MT 1.5 16V" & @CRLF & _ "Combustível:" & @CRLF & _ "ALC/GAS" & @CRLF & _ "A.3" & @CRLF & _ "Concessionária / Revenda / Lojista:CNPJ:" & @CRLF & _ "ANDRE RIBEIRO - GUAR003.962.539/0002-09" & @CRLF & _ "B" & @CRLF & _ "VALOR FINANCIADO (PRINCIPAL + ACESSÓRIOS + SERVIÇOS DE TERCEIROS FINANCIADOS" & @CRLF & _ "R$% (²)" & @CRLF & _ "A PEDIDO DO CONSUMIDOR)" & @CRLF & _ "B.1" & @CRLF & _ "60.000,00" & @CRLF & _ "Valor do veículo à vista" & @CRLF & _ "B.2" & @CRLF & _ "1,01300,00" & @CRLF & _ "Acessórios - Financiados:" & @CRLF & _ "(x)sim ( )não" & @CRLF & _ "B.3" & @CRLF & _ "IPVA - Financiado:" & @CRLF & _ "( )sim (x)não0,000,00" & @CRLF & _ "B.4" & @CRLF & _ "0,000,00" & @CRLF & _ "Multas de trânsito - Financiadas:" & @CRLF & _ "( )sim (x)não" & @CRLF & _ "B.5" & @CRLF & _ "0,000,00" & @CRLF & _ "Licenciamento - Financiado:" & @CRLF & _ "( )sim (x)não" & @CRLF & _ "B.6" & @CRLF & _ "918,363,09" & @CRLF & _ "" & @CRLF & _ "Seguro(s) - Financiado(s):" & @CRLF & _ "Seguro Casco" & @CRLF & _ "(x)sim ( )não" & @CRLF & _ "Seguradora" & @CRLF & _ "CNPJ:" & @CRLF & _ "CARDIF" & @CRLF & _ "Seguro Proteção Financeira" & @CRLF & _ "Seguro Garantia Estendida" & @CRLF & _ "" & @CRLF & _ "Seguradora" & @CRLF & _ "" & @CRLF & _ "Seguradora" & @CRLF & _ "CNPJ:" & @CRLF & _ "003.546.261/0001-08" & @CRLF & _ "CNPJ:" & @CRLF & _ "" & @CRLF & _ "0,00" & @CRLF & _ "918,36" & @CRLF & _ "0,00" & @CRLF & _ "0,00" & @CRLF & _ "3,09" & @CRLF & _ "0,00" & @CRLF & _ "B.7" & @CRLF & _ "9,102.700,00" & @CRLF & _ "(x)sim ( )não" & @CRLF & _ "Despesas com despachante:" & @CRLF & _ "CNPJ:" & @CRLF & _ "" & @CRLF & _ "B.8" & @CRLF & _ "Registro contrato - Cartório (cf. legislação estadual) - Financiadas:" & @CRLF & _ "( )sim (x)não0,000,00" & @CRLF & _ "B.9" & @CRLF & _ "0,45134,14" & @CRLF & _ "Registro contrato - Órgão de trânsito (CC, art. 1361 / Res. 320 CONTRAN) - Financiadas:" & @CRLF & _ "(x)sim ( )não" & @CRLF & _ "B.10" & @CRLF & _ "SUBTOTAL: VEÍCULO + ACESSÓRIOS + SERVIÇOS DE TERCEIROS FINANCIADOS A PEDIDO DO CONSUMIDOR" & @CRLF & _ "64.052,50" & @CRLF & _ "CPAGAMENTO INICIAL / ENTRADA" & @CRLF & _ "C.1" & @CRLF & _ "36.000,00" & @CRLF & _ "Valor da entrada" & @CRLF & _ "C.2" & @CRLF & _ "94,5228.052,50" & @CRLF & _ "Valor liberado a fornecedores" & @CRLF & _ "DADOS DE RESPONSABILIDADE DA INSTITUIÇÃO FINANCEIRA" & @CRLF & _ "TARIFAS (Conforme Resolução CMN 3.919/2010)D" & @CRLF & _ "D.1" & @CRLF & _ "Confecção de cadastro para início de relacionamento - Financiada:" & @CRLF & _ "(x)sim ( )não2,34695,00" & @CRLF & _ "D.2" & @CRLF & _ "Confecção de cadastro para início de relacionamento - (garantia de operação) - Financiada:" & @CRLF & _ "( )sim (x)não0,000,00" & @CRLF & _ "D.3Total de tarifas a serem financiadas" & @CRLF & _ "2,34695,00" & @CRLF & _ "EIOF - IMPOSTOS INCIDENTES SOBRE A OPERAÇÃO" & @CRLF & _ "E.1" & @CRLF & _ "28.747,50" & @CRLF & _ "Valor total a ser financiado sem impostos (B.10 - C.1 + D.3)" & @CRLF & _ "E.2" & @CRLF & _ "IOF - Financiado:" & @CRLF & _ "" & @CRLF & _ "Alíquota:" & @CRLF & _ "3,00" & @CRLF & _ "% a.a." & @CRLF & _ "2,75817,55" & @CRLF & _ "E.3" & @CRLF & _ "0,380,38112,32" & @CRLF & _ "IOF - Alíquota adicional (Decreto 6.339/08) - Financiado:" & @CRLF & _ "" & @CRLF & _ "Alíquota:% única" & @CRLF & _ "E.4Total de impostos a serem financiados" & @CRLF & _ "3,13929,87" & @CRLF & _ "FDADOS DO FINANCIAMENTO" & @CRLF & _ "F.1" & @CRLF & _ "Data do 1° Vencimento" & @CRLF & _ "25/11/2019" & @CRLF & _ "F.2" & @CRLF & _ "Número de parcelas mensais" & @CRLF & _ "48" & @CRLF & _ "F.3" & @CRLF & _ "Valor total das parcelas intermediárias (quando houver)" & @CRLF & _ "0,00" & @CRLF & _ "F.4" & @CRLF & _ "12,3617,66" & @CRLF & _ "Taxa de juros mensal e anual" & @CRLF & _ "% a.m.:% a.a.:" & @CRLF & _ "F.5" & @CRLF & _ "846,78" & @CRLF & _ "Valor de cada parcela mensal" & @CRLF & _ "F.6VALOR TOTAL FINANCIADO (COM IMPOSTOS) (E.1 + E.4)" & @CRLF & _ "100,0029.677,37" & @CRLF & _ "GVALOR TOTAL PAGO AO FINAL (F5 X F2) + C.1" & @CRLF & _ "76.645,44" & @CRLF & _ "HCET - CUSTO EFETIVO TOTAL DA OPERAÇÃO (FÓRMULA DA RES: 3.517/07)" & @CRLF & _ "2,33" & @CRLF & _ "CET % a.m.:" & @CRLF & _ "CET % a.a.:" & @CRLF & _ "31,88" & @CRLF & _ "I" & @CRLF & _ "Prazo de validade do orçamento (¹): 03 DIAS ÚTEIS. Local: GUARULHOS-SP Data: 25/10/2019" & @CRLF & _ "J" & @CRLF & _ "Assinatura do Consumidor:" & @CRLF & _ "`sig,uid=39818363833,pid=7312134,ufn=DANIEL AKIRA WATANABE,ut=S,pt=PA,bio=0,r=1,offX=-30,offY=-60`" & @CRLF & _ "Canais de Atendimento ao Cliente: Alô Banco Honda: (11) 2172-7080 / SAC: 0800 722 2339 / Ouvidoria: 0800 774 6633 / Pessoas com Deficiência Auditiva: 0800 722 2341 / Site: www.bancohonda.com.br." & @CRLF & _ "De acordo com a Lei Federal nº 12.741/2012, informamos as alíquotas máximas cobradas referente aos impostos federais, estaduais e municipais. PIS: 0,65%; Cofins: 4%; e ISS 5%." & @CRLF & _ "OBS: (¹) - O prazo de validade aqui apontado refere-se às condições financeiras do orçamento, apenas, e não à disponibilidade do veículo, pelo mesmo período." & @CRLF & _ "(²) - Os percentuais apresentados foram calculados com base no VALOR TOTAL FINANCIADO (F.6)" & @CRLF & _ "Agente Certificado CPF:" & @CRLF & _ "371.821.038-00" & @CRLF & _ "Nome:" & @CRLF & _ "PAMELA PRISCILA VIEIRA" & @CRLF & _ "" & @CRLF & _ "ARAEX0850" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; 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