Regular Expressions: The Emotionally Challenged Edition
Where regex meets emotional turmoil.
Subpage: Emotions in Python
A world where regex is used to detect and manipulate emotions.
Sub-subpage: Mood Swing Regex
A regex for detecting and predicting mood swings in Python.
Sub-subpage: Emotional State Machine
A state machine for tracking and managing emotions in Python.
Other emotions:
Code Examples
// Python code for detecting mood swings
pattern = r'\b(mood\s+swing)\b'
text = 'I have a mood swing'
if re.search(pattern, text):
print("Mood swing detected!")
// Python code for predicting emotions
import re
pattern = r'\b(happy|sad|angry)\b'
text = 'I am happy'
if re.search(pattern, text):
print("Emotion detected!")