Regex for matching string with double backlash or backlash followed by double quotes

I want to create a regex that satisfies the following condition:

  • Can contain any character that is not n and r. Can be empty string.
  • Can contain " and \, but " and are not allowed.

Positive examples: abc d, my "time", D:\willy\wonka, foo\"bar.

Negative examples: my "laser", D:willibadehose, foo\"bar.

I tried using positive lookbehind, but abc d is not matched and foo\"bar is matched:


How can I fix this? Here is the link to regex101 for ease of testing:

Read more here: Source link