ack (perl?) regexp matching lines where if is the first word
- by Gauthier
Hey.
I'm finally learning regexps, training with ack. I believe this uses perl regexp.
I want to match all lines where the first non-blank characters are if (<word> !, with any number of spaces in between the elements.
This is what I came up with:
^[ \t]*if *\(\w+ *!
It only nearly worked. ^[ \t]* is wrong, since it matches one or none [space or tab].
What I want is to match anything that may contain only space or tab (or nothing).
For example these should not match:
// if (asdf != 0)
else if (asdf != 1)
How can I modify my regexp for that?