Python String Manipulation and Regular Expressions

Formatting Strings: Adjusting Case

Formatting Strings: Adjusting Case

Formatting Strings: Adding and Removing Spaces

Formatting Strings: Removing Spaces

Formatting Strings: Adding Spaces

Finding and Replacing Substrings

Finding and Replacing Substrings

Splitting and Partitioning Strings

Splitting and Partitioning Strings

format Basics

format Arguments

Formatting Example with format

>>> for x in range(1,11):
...     print('{:2} {:3} {:4}'.format(x,x**2,x**3))
...
 1   1    1
 2   4    8
 3   9   27
 4  16   64
 5  25  125
 6  36  216
 7  49  343
 8  64  512
 9  81  729
10 100 1000

format Specifiers

format Specifiers: Width Option

format Specifiers: Fill and Alignment

format Specifiers: Sign option

format Specifiers: #

format Specifiers: 0

format Specifiers: Grouping Option

format Specifiers: Precision Option

format Specifiers: Type Option

format Specifiers: Type Option (Continued)

format Specifiers: Type Option

Pattern Matching with Regular Expressions

Pattern Matching with Regular Expressions

Pattern Matching with Regular Expressions

Basic Regular Expression Syntax

Regular Expression Escape Characters

Matching Character Groups

Matching Custom Character Groups

Matching Repeated Characters

Matching Repeated Characters

character description
? match zero or one
* match zero or more
+ match one or more
{n} match n repetitions
{m,n} match between ‘m’ and ‘n’

Matching Repeated Characters