0

I've seen a few answers that deal with this question but was unable to get them to work.

What is a regex that would match "LOGGED_IN" but not match "NOT_LOGGED_IN"?

Jemshit
  • 9,501
  • 5
  • 69
  • 106
eeejay
  • 5,394
  • 8
  • 29
  • 30
  • This isn't something to use RegEx for, use `.indexOf()` to check for a "NOT". That said, `/^LOGGED\_IN/i` should work fine – Downgoat Apr 09 '15 at 21:44
  • You don't need lookbehind for this. Just match a word boundary ([`\b`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#special-word-boundary)). – Joe White Apr 09 '15 at 21:55

1 Answers1

0

^LOGGED_IN$ is first to come to mind

Slaaavo
  • 112
  • 1
  • 11
  • 1
    This only works if the string is at the beginning. It won't work if he's trying to distinguish "Joe is LOGGED_IN" from "Joe is NOT_LOGGED_IN" – Barmar Apr 09 '15 at 21:50
  • True, but that was not specified in his question – Slaaavo Apr 10 '15 at 09:16