pyBegin / projects / regex-strip
🔣

Regex Strip

A small demonstration that reimplements Python's str.strip() method using regular expressions to remove leading and trailing whitespace.

23 linesRunnable

Regex Strip

A small demonstration that reimplements Python's str.strip() method using regular expressions to remove leading and trailing whitespace.

Example

The script runs on the hard-coded string " test ffs " and prints the result with leading and trailing whitespace removed:

$ python regex-strip.py
test ffs

How to run on localhost

python regex-strip.py

Dependencies

Standard library only (uses re).