Reputation: 61
Create a regular expression that will find a line with leading and/or trailing space(s).
Guys, I have no idea how to start. Anyone care to lighten me up?
Upvotes: 2
Views: 1639
Reputation: 41838
To see if such lines exist, you can use this simple regex (see online demo):
^ | $
To actually match the lines, use this (see online demo):
^(?: .*$|.* $)
To match a the spaces, use this (see online demo):
^ +| +$
Upvotes: 1
Reputation: 174696
Your regex would be like this to find the lines which has leading and trailing spaces,
^ +.* +$
Upvotes: 0