Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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

/
/
s

Test String

Code Generator

Generated Code

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r#"(?s)<p><span style=\"font\-size:16px\">(.*)?<\/span><\/p>"#).unwrap(); let string = "<div class=\"text\"> <p><span style=\"font-size:16px\">As notas do Exame Nacional do Ensino Médio (Enem) 2017 foram divulgadas nesta quinta-feira (18). O resultado deve ser consultado individualmente: para isso, os candidatos devem acessar a Página do Participante (https://enem.inep.gov.br/participante/) e incluir CPF e a senha cadastrada. </span></p> <p><span style=\"font-size:16px\">O resultado dos treineiros só será divulgado em 19 de março. Na mesma data, o Ministério da Educação também vai disponibilizar os chamados \"espelhos da redação\", que são a cópia digitalizada dos textos e as justificativas para as notas. </span></p> <p><span style=\"font-size:16px\">Nesta quinta, o Ministério da Educação (MEC) divulgou o balanço sobre o desempenho dos candidatos na edição de 2017 do exame. Apenas 53 alunos tiraram nota mil na redação, porém a nota média subiu de 541,9 para 558. Neste ano, os candidatos escreveram sobre o tema \"Desafios para a formação educacional de surdos no Brasil\".</span></p> <p><span style=\"font-size:16px\">Com a nota do Enem 2017, os estudantes podem concorrer a uma vaga em uma universidade pública que tenha aderido ao Sistema de Seleção Unificada (Sisu) 2018. As vagas já podem ser consultadas. Serão 130 instituições no Brasil - 30 estaduais e 100 federais -, que ofertarão 239.601 vagas na graduação.</span></p> <p><span style=\"font-size:16px\">Para participar, é necessário ter tirado nota acima de zero na redação do Enem 2017. Como nos anos anteriores, cada candidato poderá se inscrever em até duas vagas, especificando a ordem de preferência e o turno no qual pretende estudar. </span></p> <p><span style=\"font-size:16px\">A pesquisa está registrada sob o número TSE: PA-0472/2012.</span></p> </div> .</span></p> <p><span style=\"font-size:16px\">O levantamento, encomendado pela Rede Amazônica, retransmissora da Rede Globo, divulgado nesta sexta-feira, 5, foi feito entre os dias 3 a 5 de outubro , com 812 entrevistados. A margem de erro é 3 pontos percentuais, e o nível de confiança é de 95%.</span></p>"; // result will be a tuple containing the start and end indices for the first match in the string let result = regex.captures(string); let (start, end) = match result { Some((s, e)) => (s, e), None => { // ... } }; println!("{}", &string[start, end]); }

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 Rust, please visit: https://docs.rs/regex/latest/regex/