Regexp to match characters that are not flowing by a character that repeats several times

I built this regular expression to match the letters, numbers, and points of a
point only if they do not repeat successfully
Example:

something.somethnElse.another.then.something

this is a coincidence because the points are separated. but in the following case:

something..thensomething

does not match, because next to each other there is one or more points this is my regexp, I recommend, please, why it does not work

[a-zA-Z0-9\.]+(?!\.{2,})

I also tried

[a-zA-Z0-9\.]+(?![\.]+)

but both of them give correspondence for successful points

+4
source share
3 answers

You are close. You can use this regex:

^(?!.*?\.{2})[a-zA-Z0-9.]+$

RegEx Demo

PS:

+2

^ $ lookahead .

/^(?!.*\.{2})[a-z0-9.]+$/i

Live Demo

+2

First of all, the expression must be bound, otherwise only a minimal match is required.

In addition, you can think of your expression as a chain of letters and numbers that can be interrupted by exactly one dot.

So:

/^(?:[a-z0-9]+|\.(?!\.))*$/
+2
source

All Articles