1

I'm trying to use regex to filter a list of site that doesn't include a specific word.

For example from the list below, i want to filter all sites with the word test and empty strings so the final output that I'll get is http://example.com. I tried to use ^((?!test).)* but that doesn't filter empty strings. Maybe there is a better way to filter them? Thanks.

http://test1.com
http://test2.com
*empty string*
http://example.com
1
  • You can use: ^(?!.*test).+ Commented Jun 8, 2017 at 14:58

1 Answer 1

1

You need to use a negative lookahead and .+ in your regex as this:

^(?!.*test).+

RegEx Demo

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.