Advanced Patterns

For the Truly Insane

Warning: what you are about to read may cause permanent brain damage. Proceed with caution.

Also known as "Regular Expressions Gone Wild in Python" (RGGWIP)

This is for the regex wizards who dare to tread where mortals fear to go.

Back to the Main Menu

Example 1: Matching Anything

Example 1: Matching Anything

.* matches anything

This is not a drill

This regex is for the truly insane

Use with caution, or not.

Example 2: Capturing Groups

Example 2: Capturing Groups

Use parentheses to capture groups, like this: (group1)

Groups are like containers for your captured text, like little boxes

They can be numbered, like \1, \2, etc.

Don't try to open them, they're just for looking.

Example 3: Negative Lookahead Assertion Example 3: Negative Lookahead Assertion

Not a drill, not a joke, not even a regex.

This is the part where you learn about the negative lookahead assertion

Which is not the same as a positive lookahead assertion

Don't get it twisted.

Back to the Main Menu

Back to the Main Menu

Because you clearly need a refresher