Reputation: 597
I want to make sure there are at least 1 characters before the finial dot, then make sure sure there is atleast 2 characters after the final dot...
link_regex = /^.+\..+$/i;
Doesn't work like that, I thought the .+ would be greedy and grab everything up to the last final dot.
Upvotes: 0
Views: 159
Reputation: 198556
Huh? It works, but not exactly what you said - it will accept one character before and one character after the last dot. You need ^.+\.[^.]{2,}$
for what you described.
Upvotes: 1
Reputation: 527538
link_regex = /^.+\.[^.]{2,}$/i;
[^.]
is any non-period character; {2,}
says "2 or more".
Upvotes: 3