Reputation: 11
I'm trying to write Regex to find lines in a files where commands are not using absolute paths. Unfortunately, there are spacing issues with these lines.
// PATHS
pathmunge /absolute/path
pathmunge ~not/absolute/path
pathmunge /absolute/path
// matches
pathmunge ~not/absolute/path
My expression matches the lines where there are spaces at the beginning and before pathmunge
string, but it doesn't find the lines with variable-length whitespace but without a "/" as the next non-whitespace character.
So far, I have:
^(?=\s+pathmunge)\s+(?!\/).*$
Any help is appreciated.
Upvotes: 1
Views: 118
Reputation: 91430
Remove the lookahead and make the space possessive:
^\s*pathmunge\s++(?!\/).*$
Upvotes: 1