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