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
  • 13,742
  • 6
  • 28
  • 51
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
  • 127,136
  • 16
  • 45
  • 63
0

You need to escape special characters.

/\/(!ut)\//

or

/\/!ut\//
Lucas Wieloch
  • 818
  • 6
  • 18