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

use strict; my $str = 'Every day, millions of users interact with each other via graphical avatars in real time in online games (Chan & Vorderer, 2006). All of them are using an avatar that differs from their physical appearance. In fact, most of them are using avatars that are attractive, powerful, youthful, and athletic. Although most research in CMC has focused on the technical affordances of the medium (lack of social cues, social pre- sence, anonymity, etc.), we argue that theoretical frameworks of self-representation cannot be ignored because choosing who we are is a fundamental aspect of virtual environments. More importantly, who we choose to be in turn shapes how we be- have. Although avatars are usually construed as something of our own choosing— a one-way process—the fact is that our avatars come to change how we behave. Acknowledgments The current work was partially supported by National Science Foundation (NSF) Grant 0527377. The authors would like to thank Claire Carlson, Gerron Crochet, and Kathryn Rickertsen for their assistance in conducting the experiment, as well as Jim Blascovich for providing helpful feedback on an earlier draft of the paper. Notes 1 In the analysis of Experiment 1, there was no significant interaction effect with the race of the participant. In Experiment 2, participants do not see their own avatar, so this was not an issue. 2 In both studies, the effect of subject gender was not significant, and including this factor in the ANOVA did not change the reported significance of the results. Human Communication Research 33 (2007) 271–290 ª 2007 International Communication As287iation The Proteus Effect N. Yee & J. Bailenson 3 In the cases where this caused a mismatch between the perceived and actual height of the participant’s avatar, real-time algorithms using trigonometry were used to correct the eye-gaze angle between the participant and the confederate to preserve the possibility of making eye contact. References 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. Linden Labs (2006). What is second life? Retrieved May 5, 2006, from lindenlab.com/ ProductFactSheet.pdf Fearon, J. D., & Laitin, D. D. (2003). Ethnicity, Insurgency, and Civil War. American Political Science Review, 97(01), 75. doi: 10.1017/S0003055403000534 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 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. Human Communication Research, 31, 511–537.'; my $regex = qr/^(?<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>[^.()]+))?/mp; if ( $str =~ /$regex/g ) { print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n"; # print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n"; # print "Capture Group 2 is $2 ... and so on\n"; } # ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p' # Named capture groups can be called via $+{name}

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 Perl, please visit: http://perldoc.perl.org/perlre.html