Objective

Work with strings, formatting, and regular expressions in Python.

Tools & Technologies

  • Python 3
  • str
  • re
  • format

Key Commands

f'Hello {name}'
s.split(',')
','.join(lst)
re.findall(r'\d+', text)
s.strip().lower()

Lab Steps

01
String Methods

Apply split, join, strip, replace, and case methods.

02
f-strings

Use f-string formatting for readable string interpolation.

03
Regex in Python

Use the re module for pattern matching and extraction.

04
String Parsing

Parse structured text like CSV, log lines, and config files.

Challenges Encountered

  • Regex backslash escaping in raw strings
  • f-string expressions cannot contain backslashes

Key Takeaways

  • f-strings are faster and more readable than % or .format()
  • Compile regex patterns with re.compile() for reuse