Regex with detailed explanation. -- How can we write the regular expression???

First, let us consider numbers without sign and e.
Here are four cases: 0, 0., .0, 0.0. And we can divide them into two cases: {0, 0., 0.0}, {.0}.
In the first case, we have regular expression: \\d+(\\.\\d*)?, and in the second case we have \\.\\d+
So, the numbers without sign and e can be written to \\d+(\\.\\d*)?|\\.\\d+.

Second, let us consider e, and there are three cases: e1, e+1, e-1, which can be written to e[+-]?\\d+.

Third, let us consider sign, which can be written to [+-]?

In a word, valid number can be written to [+-]?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?,
and the code: