-1

After countless hours of trying to get this regex to work (including looking all over StackOverflow), I thought I'd reach out for help on here as I have not been successful).

I have tried creating a regex to match everything and to not match any parameters that look like this:

  • text=3242ffs3F34

The data after the = sign can be random (its a mixture of numeric and string characters) and is never the same. So far I have created the following regex below, which is almost doing what I am after but it does not work.

\b(?!text=.*)\b\S+

Assistance is much appreciated!

EDIT:

I will be using the regex to match everything in a file but to filter out all parameters that look like this:

  • text=3242ffs3F34

Below is an example of how the config file will look like:

This is a test
test=asda
test2=22rr2
text=3242ffs3F34
test5=hello
Paolo
  • 10,935
  • 6
  • 23
  • 45
Help
  • 41
  • 1
  • 2
  • 9
  • I saw this almost exact question here about 12 hours ago, under a different username/account. At that time, you received several comments that your question was not clear. Please edit your question and show us several samples of input, along with what you want to match. – Tim Biegeleisen Aug 13 '18 at 15:17

1 Answers1

0

To match everything except strings containing LAST_DOMINO_TIME= as substring you can use the expression:

(?!.*\bLAST_DOMINO_TIME=.*$)^.*$
  • (?! Negative lookahead.
    • .* Match anything.
    • \b Word boundary.
    • LAST_DOMINO_TIME= Literal substring.
    • .*$ Anything up to end of string.
  • ) Close lookahead.
  • ^.*$ Assert position beginning of line, match anything up to end of line.

You can try it here.

Paolo
  • 10,935
  • 6
  • 23
  • 45