0

I would like to exclude any line in the document that has /!ut/ I know / is a special character in regex so tried below and does not seem to be working as expected.

//!ut//
//(!ut)//

Any help is appreciated.

Paolo
  • 21,270
  • 6
  • 38
  • 69
JGD
  • 1

2 Answers2

1

You don't have to escape the forward slash in a regex, but you do when it is used as a delimiter

If you change your regexes to match a single forward slash with or without escaping them, /!ut/ would match that literally and /(!ut)/ would match that literally with !ut in a capturing group.

What you could do to exclude any line that contains /!ut/ is to use a negative lookahead (?!.*/!ut/) to make sure that what follows is not /!ut/ and then match the rest of the line using .*$

^(?!.*\/!ut\/).+$

Regex demo

The fourth bird
  • 154,723
  • 16
  • 55
  • 70
0

You need to escape special characters.

/\/(!ut)\//

or

/\/!ut\//
Lucas Wieloch
  • 818
  • 7
  • 19