Regular Expressions 101

Community Patterns

1...56789...283

Trim whitespace at beginning and/or end of a line

0

Regular Expression
Python

r"
^\s*(\S.*\S)\s*$
"
gm

Description

identifies spaces at the beginning and end of lines. Can be used as a Trim function

Submitted by Eric Hills - a year ago