1

Sorry if the answer was out there somewhere. I did my research but couldn't find it.

I want to build a regular expression pattern that will match a line in the following format:

  1. Begins with the word "sccp"
  2. Followed by a space
  3. Followed by anything except "ccm group"

I know that ^ in square brackets means "except for any of the characters". How do I exclude a phrase instead of single characters? Obviously, the pattern below didn't do what I wanted:

^sccp [^ccm group]

Thanks!

1 Answer 1

1

You should be able to use ^sccp (?!ccm group) or ^sccp (?!ccm group).* which uses a negative lookahead to assert that the phrase "ccm group" does not come after the space. Try it here.

If "sccp " should not match (i.e. nothing after the space), then use ^sccp (?!ccm group).+.

Information on the negative lookahead can be found here.

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

Comments

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.