Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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

/
/
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)^(?<author>(?:(?!$)[A-Za-z\s&.,'’])+)\((?<year>\d{4})\)\.?\s*(?<title>[^?.!]+?[.?!])\s*(?:(?<retrieved>[Rr]etrieved.+)|(?:(?:(?<jurnal>(?:(?!^[A-Z])[^,])+?),\s*(?<issue>\d+)))|\s*In(?<editors>[^\(]+)\(Eds\.\),(?<book>[^.()]+))?" Local $sString = "Every day, millions of users interact with each other via graphical avatars in real" & @CRLF & _ "time in online games (Chan & Vorderer, 2006). All of them are using an avatar that" & @CRLF & _ "" & @CRLF & _ "differs from their physical appearance. In fact, most of them are using avatars that" & @CRLF & _ "are attractive, powerful, youthful, and athletic. Although most research in CMC has" & @CRLF & _ "focused on the technical affordances of the medium (lack of social cues, social pre-" & @CRLF & _ "" & @CRLF & _ "sence, anonymity, etc.), we argue that theoretical frameworks of self-representation" & @CRLF & _ "cannot be ignored because choosing who we are is a fundamental aspect of virtual" & @CRLF & _ "environments. More importantly, who we choose to be in turn shapes how we be-" & @CRLF & _ "" & @CRLF & _ "have. Although avatars are usually construed as something of our own choosing—" & @CRLF & _ "a one-way process—the fact is that our avatars come to change how we behave." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Acknowledgments" & @CRLF & _ "" & @CRLF & _ "The current work was partially supported by National Science Foundation (NSF)" & @CRLF & _ "Grant 0527377. The authors would like to thank Claire Carlson, Gerron Crochet, and" & @CRLF & _ "" & @CRLF & _ "Kathryn Rickertsen for their assistance in conducting the experiment, as well as Jim" & @CRLF & _ "Blascovich for providing helpful feedback on an earlier draft of the paper." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Notes" & @CRLF & _ "" & @CRLF & _ "1 In the analysis of Experiment 1, there was no significant interaction effect with the race" & @CRLF & _ "" & @CRLF & _ " of the participant. In Experiment 2, participants do not see their own avatar, so this was" & @CRLF & _ " not an issue." & @CRLF & _ "2 In both studies, the effect of subject gender was not significant, and including this factor" & @CRLF & _ " in the ANOVA did not change the reported significance of the results." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Human Communication Research 33 (2007) 271–290 ª 2007 International Communication As287iation" & @CRLF & _ "The Proteus Effect N. Yee & J. Bailenson" & @CRLF & _ "" & @CRLF & _ "3 In the cases where this caused a mismatch between the perceived and actual height of the" & @CRLF & _ "" & @CRLF & _ " participant’s avatar, real-time algorithms using trigonometry were used to correct the" & @CRLF & _ " eye-gaze angle between the participant and the confederate to preserve the possibility of" & @CRLF & _ " making eye contact." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "References" & @CRLF & _ "" & @CRLF & _ "Anonymous. (1998). To reveal or not to reveal: A theoretical model of anonymous" & @CRLF & _ " communication. Communication Theory, 8, 381–407." & @CRLF & _ "" & @CRLF & _ "Bailenson, J. (2006). Transformed social interaction in collaborative virtual environments." & @CRLF & _ " In P. Messaris & L. Humphreys (Eds.), Digital media: Transformations in human" & @CRLF & _ " communication (pp. 255–264). New York: Peter Lang." & @CRLF & _ "" & @CRLF & _ "Bailenson, J., Beall, A., Blascovich, J., Loomis, J., & Turk, M. (2005). Transformed social" & @CRLF & _ " interaction, augmented gaze, and social influence in immersive virtual environments." & @CRLF & _ "" & @CRLF & _ "Linden Labs (2006). What is second life? Retrieved May 5, 2006, from lindenlab.com/ ProductFactSheet.pdf" & @CRLF & _ "Fearon, J. D., & Laitin, D. D. (2003). Ethnicity, Insurgency, and Civil War. American Political Science Review, 97(01), 75. doi: 10.1017/S0003055403000534" & @CRLF & _ "Jacobson, D. (1999). Impression formation in cyberspace: Online expectations and offline experiences in text-based virtual communities. Journal of Computer-Mediated Communication, 5. Retrieved April 26, 2007, from http://jcmc.indiana.edu/vol5/issue1/ jacobson.html" & @CRLF & _ "" & @CRLF & _ "Chan, E., & Vorderer, P. (2006). Massively multiplayer online games. In P. Vorderer &" & @CRLF & _ " J. Bryant (Eds.), Playing computer games—Motives, responses, and consequences. Mahwah," & @CRLF & _ "" & @CRLF & _ " NJ: Lawrence Erlbaum." & @CRLF & _ "Culnan, M. J., & Markus, M. L. (1987). Information technologies. In F. M. Jablin &" & @CRLF & _ " L. L. Putnam (Eds.), Handbook of organizational communication: An interdisciplinary" & @CRLF & _ "" & @CRLF & _ " perspective (pp. 420–443). Thousand Oaks, CA: Sage Publications." & @CRLF & _ "Dion, K., Berscheid, E., & Walster, E. (1972). What is beautiful is good. Journal of Personality and Social Psychology, 24, 285–290." & @CRLF & _ "" & @CRLF & _ "Flanagin, A. J., Tiyaamornwong, V., O’Connor, J., & Seibold, D. R. (2002)." & @CRLF & _ " Computer-mediated group work: The interaction of member sex and anonymity." & @CRLF & _ "" & @CRLF & _ " Communication Research, 29, 66–93." & @CRLF & _ "Forsythe, R., Horowitz, J., Savin, N., & Sefton, M. (1994). Fairness in simple bargaining" & @CRLF & _ " experiments. Games and Economic Behavior, 6, 347–369." & @CRLF & _ "" & @CRLF & _ "Frank, M., & Gilovich, T. (1988). The dark side of self and social perception: Black uniforms" & @CRLF & _ " and aggression in professional sports. Journal of Personality and Social Psychology, 54," & @CRLF & _ " 74–85." & @CRLF & _ "" & @CRLF & _ "Freedman, D. G. (1979). Human sociobiology. New York: Free Press." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "288 Human Communication Research 33 (2007) 271–290 ª 2007 International Communication Association" & @CRLF & _ "N. Yee & J. Bailenson The Proteus Effect" & @CRLF & _ "" & @CRLF & _ "Friend, R. M., & Vinson, M. (1974). Leaning over backward: Jurors responses to defendants’" & @CRLF & _ "" & @CRLF & _ " attractiveness. Journal of Communication, 24, 124–129." & @CRLF & _ " Human Communication Research, 31, 511–537." 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