A pattern that matches all but a word with words

How to set a regular expression pattern that matches all words, but lines starting with

  • / word
  • / word /
  • / word /, following anything else.

I think the pattern starts with \ A, but I don’t know how to say that I should not follow the word

thank

+3
source share
4 answers

Use this type of regex expression and replace the word with the word.

^((?!word).)*$
+4
source

You can use regex:

^(?!\\/word).*$

Take a look

+2
source

Take a look at the lookaround function suggested by regular expressions. In addition, a similar stream . Also, posting your question in terms of a specific problem with the sample can help you get some working snippets.

+1
source

Perhaps string comparisons will be clearer and faster.

if (text.startsWith("word")) {
   // text is OK
} else {
   // not OK
}
+1
source

All Articles