David Picksley
David Picksley

Reputation: 266

Regex Criteria - Match on either 2 dots, 1 dot at the beginning, or both

I'm looking to create a REGEX that causes a match on the following criteria

My knowledge is quite limited on this!

I've tried to set up my own and can get a match on either, but not both?

 /(^[.])|(\b([.][.])) /gm

Any help would be much appreciated!

The expected outcome is

phrase = pass

.phrase = fail

ph..rase = fail

..phrase = fail

Upvotes: 0

Views: 20

Answers (1)

Pushpesh Kumar Rajwanshi
Pushpesh Kumar Rajwanshi

Reputation: 18357

You can use this regex, which will fail the match if the very first character is a literal dot or two literal dots are present anywhere in the text,

^(?!.*\.\.|\.).*$

Demo

Upvotes: 1

Related Questions