Solution Explanations: Regular Expressions
Review solution explanations for the code challenges on regular expressions.
Solution 1: Shorthand character classes
Here’s the solution:
Press + to interact
main.py
practice_logs.csv
import pandas as pdimport reip_addresses_df = pd.read_csv('practice_logs.csv')ip_addresses_df = ip_addresses_df['LogText'].str.extract(r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')print(ip_addresses_df)
Let’s go through the solution explanation:
Line 5: We extract IP addresses using the ...
Get hands-on with 1400+ tech skills courses.