We want to introduce additional factory functions for creating an instance of Zero from the string representation of Any object.
The regular expression used for validating inputs should be the following: ^[+-]?0+(?:\.0+)?$.
Here's the explanation associated to each symbol used in this pattern:
^Beginning. Matches the beginning of the string, or the beginning of a line if the multiline flag (m) is enabled.
[]Character set. Matches any character in the set.
+Character. Matches a "+" character (char code 43).
-Character. Matches a "-" character (char code 45).
?Quantifier. Match between 0 and 1 of the preceding token.
0Character. Matches a "0" character (char code 48).
+Quantifier. Match 1 or more of the preceding token.
(?:)Non-capturing group. Groups multiple tokens together without creating a capture group.
\.Escaped character. Matches a "." character (char code 46).
$End. Matches the end of the string, or the end of a line if the multiline flag (m) is enabled.
Here's the Application Programming Interface (API) goal:
interface Zero {
companion object {
const val PATTERN: String
fun fromString(number: Any): Zero
fun fromStringOrNull(number: Any): Zero?
}
}
β Checklist
[x] β¨ Add the PATTERN property with tests, documentation and samples.
[x] β¨ Add the fromStringOrNull function with tests, documentation and samples.
[x] β¨ Add the fromString function with tests, documentation and samples.
[x] π Add an entry for this issue in the unreleased changelog.
π Description
We want to introduce additional factory functions for creating an instance of
Zero
from the string representation ofAny
object.The regular expression used for validating inputs should be the following:
^[+-]?0+(?:\.0+)?$
. Here's the explanation associated to each symbol used in this pattern:^
Beginning. Matches the beginning of the string, or the beginning of a line if the multiline flag (m) is enabled.[]
Character set. Matches any character in the set.+
Character. Matches a "+" character (char code 43).-
Character. Matches a "-" character (char code 45).?
Quantifier. Match between 0 and 1 of the preceding token.0
Character. Matches a "0" character (char code 48).+
Quantifier. Match 1 or more of the preceding token.(?:)
Non-capturing group. Groups multiple tokens together without creating a capture group.\.
Escaped character. Matches a "." character (char code 46).$
End. Matches the end of the string, or the end of a line if the multiline flag (m) is enabled.Here's the Application Programming Interface (API) goal:
β Checklist
PATTERN
property with tests, documentation and samples.fromStringOrNull
function with tests, documentation and samples.fromString
function with tests, documentation and samples.