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

$re = '/^(?<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))/m'; $str = ' Anonymous. (1998). To reveal or not to reveal: A theoretical model of anonymous communication. Communication Theory, 8, 381–407. Bailenson, J. (2006). Transformed social interaction in collaborative virtual environments. In P. Messaris & L. Humphreys (Eds.), Digital media: Transformations in human communication (pp. 255–264). New York: Peter Lang. Bailenson, J., Beall, A., Blascovich, J., Loomis, J., & Turk, M. (2005). Transformed social interaction, augmented gaze, and social influence in immersive virtual environments. Human Communication Research, 31, 511–537. Bailenson, J., Blascovich, J., Beall, A., & Loomis, J. (2003). Interpersonal distance in immersive virtual environments. Personality and Social Psychology Bulletin, 29, 1–15. Bem, D. (1972). Self perception theory. In L. Berkowitz (Ed.), Advances in experimental social psychology (Vol. 6). New York: Academic Press. Blascovich, J., Loomis, J., Beall, A., Swinth, K., Hoyt, C., & Bailenson, J. (2002). Immersive virtual environment technology as a methodological tool for social psychology. Psychological Inquiry, 13(2), 103–124. Burgoon, J. (1978). A communication model of personal space violation: Explication and an initial test. Human Communication Research, 4, 129–142. Burgoon, J., & Walther, J. (1990). Nonverbal expectancies and the evaluative consequences of violations. Human Communication Research, 17, 232–265. Burgoon, J., Walther, J., & Baesler, E. (1992). Interpretations, evaluations, and consequences of interpersonal touch. Human Communication Research, 19, 237–263. Chan, E., & Vorderer, P. (2006). Massively multiplayer online games. In P. Vorderer & J. Bryant (Eds.), Playing computer games—Motives, responses, and consequences. Mahwah, NJ: Lawrence Erlbaum. Culnan, M. J., & Markus, M. L. (1987). Information technologies. In F. M. Jablin & L. L. Putnam (Eds.), Handbook of organizational communication: An interdisciplinary perspective (pp. 420–443). Thousand Oaks, CA: Sage Publications. Dion, K., Berscheid, E., & Walster, E. (1972). What is beautiful is good. Journal of Personality and Social Psychology, 24, 285–290. Flanagin, A. J., Tiyaamornwong, V., O’Connor, J., & Seibold, D. R. (2002). Computer-mediated group work: The interaction of member sex and anonymity. Communication Research, 29, 66–93. Forsythe, R., Horowitz, J., Savin, N., & Sefton, M. (1994). Fairness in simple bargaining experiments. Games and Economic Behavior, 6, 347–369. Frank, M., & Gilovich, T. (1988). The dark side of self and social perception: Black uniforms and aggression in professional sports. Journal of Personality and Social Psychology, 54, 74–85. Freedman, D. G. (1979). Human sociobiology. New York: Free Press. 288 Human Communication Research 33 (2007) 271–290 ª 2007 International Communication Association N. Yee & J. Bailenson The Proteus Effect Friend, R. M., & Vinson, M. (1974). Leaning over backward: Jurors responses to defendants’ attractiveness. Journal of Communication, 24, 124–129. Gergen, K., Gergen, M., & Barton, W. H. (1973). Deviance in the dark. Psychology Today, 11, 129–130. Hancock, J., & Dunham, P. (2001). Impression formation in computer-mediated communication revisited: An analysis of the breadth and intensity of impressions. Communication Research, 28, 325–347. Harrison, A. A., & Saeed, L. (1977). Let’s make a deal: An analysis of revelations and stipulations in lonely hearts advertisements. Journal of Personality and Social Psychology, 35, 257–264. Hiltz, S., Johnson, K., & Turoff, M. (1986). Experiments in group decision making: Communication processes and outcome in face-to-face versus computerized conferences. Human Communication Research, 13, 225–252. 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 Jarvenpaa, S., & Leidner, D. (1998). Communication and trust in global virtual teams. Journal of Computer-Mediated Communication, 3. Retrieved April 26, 2007, from http:// jcmc.indiana.edu/vol3/issue4/jarvenpaa.html Johnson, R., & Downing, L. (1979). Deindividuation and valence of cues: Effects on prosocial and antisocial behavior. Journal of Personality and Social Psychology, 37, 1532–1538. Kiesler, S., Siegel, J., & McGuire, T. W. (1984). Social psychological aspects of computer-mediated communication. American Psychologist, 39, 1123–1134. Langlois, J., Kalakanis, L., Rubenstein, A., Larson, A., Hallam, M., & Smoot, M. (2000). Maxims or myths of beauty?: A meta-analytic and theoretical review. Psychological Bulletin, 126, 390–423. Lea, M., O’Shea, T., & Spears, R. (1992). ‘‘Flaming’’ in computer-mediated communication. In M. Lea (Ed.), Contexts of computer-mediated communication (pp. 89–112). New York: Harvester Wheatsheaf. Linden Labs (2006). What is second life? Retrieved May 5, 2006, from lindenlab.com/ ProductFactSheet.pdf Loomis, J., Blascovich, J., & Beall, A. (1999). Immersive virtual environments as a basic research tool in psychology. Behavior Research Methods, Instruments, and Computers, 31, 557–564. McKenna, K., & Bargh, J. (2000). Plan 9 from cyberspace: The implications of the Internet for personality and social psychology. Personality and Social Psychology Review, 4, 57–75. Merola, N., Penas, J., & Hancock, J. (2006). Avatar color and social identity effects: On attitudes andgroupdynamics invirtualrealities. Paper presented at the ICA 2006, Dresden, Germany. National Center for Health Statistics (2004). National health and nutrition examination survey 2003-2004. Retrieved September 5, 2006, from http://www.cdc.gov/nchs/about/ major/nhanes/nhanes2003-2004/nhanes03_04.htm Normand, V., Babski, C., Benford, S., Bullock, A., Carion, S., Chrysanthou, Y, et al. (1999). The COVEN project: Exploring applicative, technical, and usage dimensions of collaborative virtual environment. Presence: Teleoperators and Virtual Environments, 8, 218–236. Human Communication Research 33 (2007) 271–290 ª 2007 International Communication Associati289 The Proteus Effect N. Yee & J. Bailenson Parks, M. R., & Floyd, K. (1996). Making friends in cyberspace. Journal of Communication, 46, 80–96. Postmes, T., & Spears, R. (2002). Behavior online: Does anonymous computer communication reduce gender inequality? Personality & Social Psychology Bulletin, 28, 1073–1083. Postmes, T., Spears, R., & Lea, M. (1998). Breaching or building social boundaries? Communication Research, 25, 689–699. Postmes, T., Spears, R., & Lea, M. (2000). The formation of group norms in computer-mediated communication. Human Communication Research, 26, 341–371. Short, J., Williams, E., & Christie, B. (1976). The social psychology of telecommunications. London: Wiley. Snyder, M., Tanke, E. D., & Berscheid, E. (1977). Social perception and interpersonal behavior: On the self-fulfilling nature of social stereotypes. Journal of Personality & Social Psychology, 35, 656–666. Spears, R., & Lea, M. (1994). Panacea or panopticon? The hidden power in computer-mediated communication. Communication Research, 21, 427–459. Stogdill, R. M. (1948). Personal factors associated with leadership: A survey of the literature. Journal of Psychology, 25, 35–71. Trevino, L., & Webster, J. (1992). Flow in computer-mediated communication: electronic mail and voice mail evaluation and impacts. Communication Research, 19, 539–573. Turkle, S. (1995). Life on the screen: Identity in the age of the Internet: New York: Simon and Schuster. Valins, S. (1966). Cognitive effects of false heart-rate feedback. Journal of Personality and Social Psychology, 4, 400–408. Walther, J. (1996). Computer-mediated communication: Impersonal, interpersonal, and hyperpersonal interaction. Communication Research, 23(1), 3–43. Walther, J., Anderson, J., & Park, D. (1994). Interpersonal effects in computer-mediated interaction: A meta-analysis of social and anti-social communication. Communication Research, 21, 460–487. Walther, J., Slovacek, C., & Tidwell, L. (2001). Is a picture worth a thousand words?: Photographic images in long-term and short-term computer-mediated communication. Communication Research, 28, 105–134. Yee, N. (2006). The demographics, motivations, and derived experiences of users of massively multi-user online graphical environments. Presence: Teleoperators and Virtual Environments, 15, 309–329. Young, T. J., & French, L. A. (1996). Height and perceived competence of U.S. Presidents. Perceptual and Motor Skills, 82, 1002. Zimbardo, P. (1969). The human choice: Individuation, reason, and order vs. deindividuation, impulse and chaos. In W. J. Arnold & D. Levine (Eds.), Nebraska symposium on motivation (Vol. 17, pp. 237–307). Lincoln: University of Nebraska Press. 290 Human Communication Research 33 (2007) 271–290 ª 2007 International Communication Association '; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php