English | 中文
I created this repo to share regex rules we may use, I'm going to improve and fix these rules, and add more rules , if you find any problem(a wrong rule; a simplable rule) or just wand to make it better, create a pull request and I would merge if it's ok , thanks!
Pattern /^(0|[1-9]\d*)(\.\d*[1-9])?$/
Tests
- ❌
0123
(leading0
not allowed) - ❌
123.
(point without fraction part not allowed) - ❌
123.0
(one or more0
as fraction part not allowed) - ✅
123.01
Check full description for email addresses, Click, But it's too complex. So here We use the gmail rules, ie "only letters, numbers and periods(.) allowed, periods(.) not allowed at first and last place, and can't be consecutive."
Here we won't check the
@
character and domain part.
Pattern /^[A-Za-z0-9]+(\.[A-Za-z0-9])*$/
Tests
- ❌
abc
.abc
a..bc
abc.
- ✅
abc
a.bc
a.b.c