0

I am trying to figure out how I ignore empty lines with spaces but no content. I have the following

^(\s*)SetEnv

Which matches what I am looking for fine, but it also matches empty lines with just spaces

So

SetEnv blah // matches
 // also matches
// doesn't match
7
  • What programming language are you using? Commented Feb 17, 2014 at 19:26
  • PHP is what I am using. Commented Feb 17, 2014 at 19:27
  • 1
    You can use: ^ *SetEnv Commented Feb 17, 2014 at 19:30
  • You should probably replace * with + (means one or more) Commented Feb 17, 2014 at 19:31
  • 1
    Can you post some code? This shouldn't be happening. Commented Feb 17, 2014 at 19:31

1 Answer 1

1

Assuming that you use the m modifier, you can use:

^(\h*)SetEnv

or

(?m)^(\h*)SetEnv

\h only matches horizontal white-spaces.

Sign up to request clarification or add additional context in comments.

1 Comment

Never noticed the \h shorthand char class before. Thanks! +1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.