Problem Description:
Regex needs to accepts all strings of type abc.xyz.mno, it should be composed of multiple strings all joined by ‘.’. The joined strings can only contain [a-z][0-9], even capital characters are not allowed.
Valid cases
abc.bcd.edsaf.asdfds
abc.asdf123.1234adf
abc.ad
Invalid cases
abc
abc.
abc.132A
ASD
1234
1234ASF.
The solution that I came up with is this
^[a-z0-9]+\.[a-z0-9]([a-z0-9]*|\.[a-z0-9])+$
I am not sure whether this is the most efficient solution possible?
原文链接:Regex solution
© 版权声明
THE END
暂无评论内容