🔣
Regex Strip
A small demonstration that reimplements Python's str.strip() method using regular expressions to remove leading and trailing whitespace.
A small demonstration that reimplements Python's str.strip() method using regular expressions to remove leading and trailing whitespace.
A small demonstration that reimplements Python's str.strip() method using regular expressions to remove leading and trailing whitespace.
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
python regex-strip.py
Standard library only (uses re).