Jackie
Jackie

Reputation: 23477

How to ensure, using regex, that a string doesn't begin with

I have code with both angular.module and module, I am trying to make sure I only get module. I tried (?!\.)(module) using regex but when it is .module it still matches.

https://regex101.com/r/snO65F/1

How can I just match ones that do not have a period?

Upvotes: 0

Views: 37

Answers (1)

ndnenkov
ndnenkov

Reputation: 36101

(?!) defines a negative lookahead.

Use (?<!) instead (negative lookbehind), assuming your regex engine supports that.

See it in action

Upvotes: 1

Related Questions