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"
"
gm

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 = "(?m)(\sdoi: 10\.\d{1,50}/\S+\..)" Local $sString = "Reliability and validity of the French version of the global physical activity questionnaire.","/pubmed/30356654","Rivière F, Widad FZ, Speyer E, Erpelding ML, Escalon H, Vuillemin A.","J Sport Health Sci. 2018 Jul;7(3):339-345. doi: 10.1016/j.jshs.2016.08.004. Epub 2016 Aug 15.","J Sport Health Sci. 2018","PubMed","citation","PMID:30356654 | PMCID:PMC6189276","pubmed","30356654","create date:2018/10/26 | first author:Rivière F" & @CRLF & _ "jbfkjezfkzjbkzvf doi: 10.3390/pharmaceutics8020011.","Pharmaceutics." & @CRLF & _ "khfkefkzefhzfe doi: 10.18632/oncotarget.8210.","Oncotarget." & @CRLF & _ "jkkgkg doi: 10.3390/molecules21091123.","Molecules." & @CRLF & _ "(3). pii: E27. doi: 10.3390/pharmacy4030027.","Pharmacy (Basel). 2016","PubMed","citation","PMID:28970400 | PMCID:PMC5419365","pubmed","28970400","create date:2017/10/04 | first author:Atkinson J"," & @CRLF & _ "63(2):175-183. doi: 10.1093/cz/zow048. Epub 2016 Apr 22.","Curr Zool. 2017","PubMed","citation","PMID:29491975 | PMCID:PMC5804161","pubmed","29491975","create date:2018/03/02 | first author:Colchen T"," & @CRLF & _ "51:209-216. doi: 10.1515/hukin-2015-0184. eCollection 2016 Jun 1.","J Hum Kinet. 2016","PubMed","citation","PMID:28149384 | PMCID:PMC5260564","pubmed","28149384","create date:2017/02/06 | first author:Rouis M"," & @CRLF & _ "11(12):e0168349. doi: 10.1371/journal.pone.0168349. eCollection 2016.","PLoS One. 2016","PubMed","citation","PMID:28036335 | PMCID:PMC5201304","pubmed","28036335","create date:2016/12/31 | first author:Huttin O"," & @CRLF & _ "14(9):1124-1137. doi: 10.1080/15476286.2016.1251543. Epub 2016 Oct 28. Review.","RNA Biol. 2017","PubMed","citation","PMID:27791472 | PMCID:PMC5699547","pubmed","27791472","create date:2016/10/30 | first author:Schwartz S"," & @CRLF & _ "66(1):39-47. doi: 10.1016/j.jhep.2016.08.021. Epub 2016 Sep 10.","J Hepatol. 2017","PubMed","citation","PMID:27622858","pubmed","27622858","create date:2016/09/14 | first author:Pol S"," 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