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

/
/
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-Z](?:(?!$)[A-Za-z\s&.,'’])+)\((?<year>\d{4})\)\.?\s*(?<title>[^()]+?[?.!])\s*(?:(?:(?<jurnal>(?:(?!^[A-Z])[^.]+?)),\s*(?<issue>\d+)[^,.]*(?=,\s*\d+|.\s*Ret))|(?:In\s*(?<editors>[^()]+))\(Eds?\.\),\s*(?<book>[^().]+)|(?:[^():]+:[^().]+\.)|(?:Retrieved|Paper presented))" Local $sString = "" & @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 & _ " Human Communication Research, 31, 511–537." & @CRLF & _ "" & @CRLF & _ "Bailenson, J., Blascovich, J., Beall, A., & Loomis, J. (2003). Interpersonal distance in immersive" & @CRLF & _ " virtual environments. Personality and Social Psychology Bulletin, 29, 1–15." & @CRLF & _ "Bem, D. (1972). Self perception theory. In L. Berkowitz (Ed.), Advances in experimental social" & @CRLF & _ "" & @CRLF & _ " psychology (Vol. 6). New York: Academic Press." & @CRLF & _ "Blascovich, J., Loomis, J., Beall, A., Swinth, K., Hoyt, C., & Bailenson, J. (2002). Immersive" & @CRLF & _ " virtual environment technology as a methodological tool for social psychology." & @CRLF & _ "" & @CRLF & _ " Psychological Inquiry, 13(2), 103–124." & @CRLF & _ "Burgoon, J. (1978). A communication model of personal space violation: Explication and an" & @CRLF & _ " initial test. Human Communication Research, 4, 129–142." & @CRLF & _ "" & @CRLF & _ "Burgoon, J., & Walther, J. (1990). Nonverbal expectancies and the evaluative consequences of" & @CRLF & _ " violations. Human Communication Research, 17, 232–265." & @CRLF & _ "Burgoon, J., Walther, J., & Baesler, E. (1992). Interpretations, evaluations, and consequences" & @CRLF & _ "" & @CRLF & _ " of interpersonal touch. Human Communication Research, 19, 237–263." & @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" & @CRLF & _ " 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 & _ "Gergen, K., Gergen, M., & Barton, W. H. (1973). Deviance in the dark. Psychology Today," & @CRLF & _ " 11, 129–130." & @CRLF & _ "" & @CRLF & _ "Hancock, J., & Dunham, P. (2001). Impression formation in computer-mediated" & @CRLF & _ " communication revisited: An analysis of the breadth and intensity of impressions." & @CRLF & _ " Communication Research, 28, 325–347." & @CRLF & _ "" & @CRLF & _ "Harrison, A. A., & Saeed, L. (1977). Let’s make a deal: An analysis of revelations and" & @CRLF & _ " stipulations in lonely hearts advertisements. Journal of Personality and Social Psychology," & @CRLF & _ " 35, 257–264." & @CRLF & _ "" & @CRLF & _ "Hiltz, S., Johnson, K., & Turoff, M. (1986). Experiments in group decision making:" & @CRLF & _ " Communication processes and outcome in face-to-face versus computerized conferences." & @CRLF & _ " Human Communication Research, 13, 225–252." & @CRLF & _ "" & @CRLF & _ "Jacobson, D. (1999). Impression formation in cyberspace: Online expectations and offline" & @CRLF & _ " experiences in text-based virtual communities. Journal of Computer-Mediated" & @CRLF & _ "" & @CRLF & _ " Communication, 5. Retrieved April 26, 2007, from http://jcmc.indiana.edu/vol5/issue1/" & @CRLF & _ " jacobson.html" & @CRLF & _ "Jarvenpaa, S., & Leidner, D. (1998). Communication and trust in global virtual teams. Journal" & @CRLF & _ "" & @CRLF & _ " of Computer-Mediated Communication, 3. Retrieved April 26, 2007, from http://" & @CRLF & _ " jcmc.indiana.edu/vol3/issue4/jarvenpaa.html" & @CRLF & _ "Johnson, R., & Downing, L. (1979). Deindividuation and valence of cues: Effects on prosocial" & @CRLF & _ "" & @CRLF & _ " and antisocial behavior. Journal of Personality and Social Psychology, 37, 1532–1538." & @CRLF & _ "Kiesler, S., Siegel, J., & McGuire, T. W. (1984). Social psychological aspects of" & @CRLF & _ " computer-mediated communication. American Psychologist, 39, 1123–1134." & @CRLF & _ "" & @CRLF & _ "Langlois, J., Kalakanis, L., Rubenstein, A., Larson, A., Hallam, M., & Smoot, M. (2000)." & @CRLF & _ " Maxims or myths of beauty?: A meta-analytic and theoretical review. Psychological" & @CRLF & _ " Bulletin, 126, 390–423." & @CRLF & _ "" & @CRLF & _ "Lea, M., O’Shea, T., & Spears, R. (1992). ‘‘Flaming’’ in computer-mediated communication." & @CRLF & _ " In M. Lea (Ed.), Contexts of computer-mediated communication (pp. 89–112). New York:" & @CRLF & _ " Harvester Wheatsheaf." & @CRLF & _ "" & @CRLF & _ "Linden Labs (2006). What is second life? Retrieved May 5, 2006, from lindenlab.com/" & @CRLF & _ " ProductFactSheet.pdf" & @CRLF & _ "Loomis, J., Blascovich, J., & Beall, A. (1999). Immersive virtual environments as a basic" & @CRLF & _ "" & @CRLF & _ " research tool in psychology. Behavior Research Methods, Instruments, and Computers," & @CRLF & _ " 31, 557–564." & @CRLF & _ "McKenna, K., & Bargh, J. (2000). Plan 9 from cyberspace: The implications of the Internet for" & @CRLF & _ "" & @CRLF & _ " personality and social psychology. Personality and Social Psychology Review, 4, 57–75." & @CRLF & _ "Merola, N., Penas, J., & Hancock, J. (2006). Avatar color and social identity effects: On attitudes" & @CRLF & _ " andgroupdynamics invirtualrealities. Paper presented at the ICA 2006, Dresden, Germany." & @CRLF & _ "" & @CRLF & _ "National Center for Health Statistics (2004). National health and nutrition examination" & @CRLF & _ " survey 2003-2004. Retrieved September 5, 2006, from http://www.cdc.gov/nchs/about/" & @CRLF & _ " major/nhanes/nhanes2003-2004/nhanes03_04.htm" & @CRLF & _ "" & @CRLF & _ "Normand, V., Babski, C., Benford, S., Bullock, A., Carion, S., Chrysanthou, Y, et al. (1999)." & @CRLF & _ " The COVEN project: Exploring applicative, technical, and usage dimensions of" & @CRLF & _ "" & @CRLF & _ " collaborative virtual environment. Presence: Teleoperators and Virtual Environments, 8," & @CRLF & _ " 218–236." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Human Communication Research 33 (2007) 271–290 ª 2007 International Communication Associati289" & @CRLF & _ "The Proteus Effect N. Yee & J. Bailenson" & @CRLF & _ "" & @CRLF & _ "Parks, M. R., & Floyd, K. (1996). Making friends in cyberspace. Journal of Communication," & @CRLF & _ "" & @CRLF & _ " 46, 80–96." & @CRLF & _ "Postmes, T., & Spears, R. (2002). Behavior online: Does anonymous computer" & @CRLF & _ " communication reduce gender inequality? Personality & Social Psychology Bulletin, 28," & @CRLF & _ "" & @CRLF & _ " 1073–1083." & @CRLF & _ "Postmes, T., Spears, R., & Lea, M. (1998). Breaching or building social boundaries?" & @CRLF & _ " Communication Research, 25, 689–699." & @CRLF & _ "" & @CRLF & _ "Postmes, T., Spears, R., & Lea, M. (2000). The formation of group norms in" & @CRLF & _ " computer-mediated communication. Human Communication Research, 26, 341–371." & @CRLF & _ "Short, J., Williams, E., & Christie, B. (1976). The social psychology of telecommunications." & @CRLF & _ "" & @CRLF & _ " London: Wiley." & @CRLF & _ "Snyder, M., Tanke, E. D., & Berscheid, E. (1977). Social perception and interpersonal" & @CRLF & _ " behavior: On the self-fulfilling nature of social stereotypes. Journal of Personality & Social" & @CRLF & _ "" & @CRLF & _ " Psychology, 35, 656–666." & @CRLF & _ "Spears, R., & Lea, M. (1994). Panacea or panopticon? The hidden power in" & @CRLF & _ "" & @CRLF & _ " computer-mediated communication. Communication Research, 21, 427–459." & @CRLF & _ "Stogdill, R. M. (1948). Personal factors associated with leadership: A survey of the literature." & @CRLF & _ " Journal of Psychology, 25, 35–71." & @CRLF & _ "" & @CRLF & _ "Trevino, L., & Webster, J. (1992). Flow in computer-mediated communication: electronic" & @CRLF & _ " mail and voice mail evaluation and impacts. Communication Research, 19, 539–573." & @CRLF & _ "Turkle, S. (1995). Life on the screen: Identity in the age of the Internet: New York: Simon and" & @CRLF & _ "" & @CRLF & _ " Schuster." & @CRLF & _ "Valins, S. (1966). Cognitive effects of false heart-rate feedback. Journal of Personality and" & @CRLF & _ " Social Psychology, 4, 400–408." & @CRLF & _ "" & @CRLF & _ "Walther, J. (1996). Computer-mediated communication: Impersonal, interpersonal, and" & @CRLF & _ " hyperpersonal interaction. Communication Research, 23(1), 3–43." & @CRLF & _ "Walther, J., Anderson, J., & Park, D. (1994). Interpersonal effects in computer-mediated" & @CRLF & _ "" & @CRLF & _ " interaction: A meta-analysis of social and anti-social communication. Communication" & @CRLF & _ " Research, 21, 460–487." & @CRLF & _ "Walther, J., Slovacek, C., & Tidwell, L. (2001). Is a picture worth a thousand words?:" & @CRLF & _ "" & @CRLF & _ " Photographic images in long-term and short-term computer-mediated communication." & @CRLF & _ " Communication Research, 28, 105–134." & @CRLF & _ "Yee, N. (2006). The demographics, motivations, and derived experiences of users of massively" & @CRLF & _ "" & @CRLF & _ " multi-user online graphical environments. Presence: Teleoperators and Virtual" & @CRLF & _ " Environments, 15, 309–329." & @CRLF & _ "Young, T. J., & French, L. A. (1996). Height and perceived competence of U.S. Presidents." & @CRLF & _ "" & @CRLF & _ " Perceptual and Motor Skills, 82, 1002." & @CRLF & _ "Zimbardo, P. (1969). The human choice: Individuation, reason, and order vs." & @CRLF & _ " deindividuation, impulse and chaos. In W. J. Arnold & D. Levine (Eds.), Nebraska" & @CRLF & _ "" & @CRLF & _ " symposium on motivation (Vol. 17, pp. 237–307). Lincoln: University of Nebraska Press." & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "290 Human Communication Research 33 (2007) 271–290 ª 2007 International Communication Association" & @CRLF & _ "" 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