COSC 1210 · CS I (Python) · Patterns

Pattern Lab: One Pattern, Many Sentences

Type a regular expression and see at once which sentences it matches, what group() and group(1) return, and where in-style searching goes wrong. Click a special character to insert it, or start from a pattern from class.
Pattern
re.search("", sentence)
insert:
from class:
Sentences
group(): the whole match group(1): inside the first ( ) re.sub: new text
Edit the sentences (one per line)

re.search finds only the first match and returns a match object or None. re.sub replaces every match. Click the red r to switch the raw string off and see what happens to \b.

Built to accompany COSC 1210 (CS I, Python), lecture “Why do you need a break?” (strings II). The matching runs live in your browser with JavaScript's regular expressions, which behave like Python's re for every special character used here: | ^ $ ? . * ( ) \b. Check anything else in Python itself.