A bunch of utility functions for parsing strings to the types they represent
A bunch of utility functions for parsing strings to the types they represent
(float-string? float-string)
Returns true if float-string
representss a valid float, false otherwise.
Returns true if `float-string` representss a valid float, false otherwise.
(parse-binary binary-str)
Parse binary-str
to the positive integer it represents in binary
Parse `binary-str` to the positive integer it represents in binary
(parse-binary-or-zero binary-str)
Like try-parse-binary
, but returns a 0 instead of nil.
Useful when passing return values into numeric operations.
Like `try-parse-binary`, but returns a 0 instead of nil. Useful when passing return values into numeric operations.
(parse-boolean bool-str)
Like parse-boolean-string
, but returns boolean values passed through and uses clojure's definition of truthiness for all other values
Like `parse-boolean-string`, but returns boolean values passed through and uses clojure's definition of truthiness for all other values
(parse-boolean-strict bool-str)
Like parse-boolean
, but throws an exception for values that are neither booleans nor true/false strings.
Useful for spec/conformance.
Like `parse-boolean`, but throws an exception for values that are neither booleans nor true/false strings. Useful for spec/conformance.
(parse-boolean-string bool-str)
Convert bool-str
to a boolean for the strings true/false (Any casing)
Convert `bool-str` to a boolean for the strings true/false (Any casing)
(parse-double double-string)
Parse double-string
to an instance of the JVM's Double class
Parse `double-string` to an instance of the JVM's Double class
(parse-double-or-zero double-string)
Like try-parse-double
, but returns 0.0 instead of nil.
Useful when passing return values into numeric operations.
Like `try-parse-double`, but returns 0.0 instead of nil. Useful when passing return values into numeric operations.
(parse-float float-string)
Parse float-string
to the floating point decimal it represents
Parse `float-string` to the floating point decimal it represents
(parse-float-or-zero float-string)
Like try-parse-float
, but returns 0.0 instead of nil.
Useful when passing return values into numeric operations.
Like `try-parse-float`, but returns 0.0 instead of nil. Useful when passing return values into numeric operations.
(parse-guid guid-str)
Parse guid-str
to the GUID it represents
Parse `guid-str` to the GUID it represents
(parse-hex hex-str)
Parse hex-str
to the positive integer it represents in hexidecimal
Parse `hex-str` to the positive integer it represents in hexidecimal
(parse-hex-or-zero hex-str)
Like try-parse-hex
, but returns a 0 instead of nil.
Useful when passing return values into numeric operations.
Like `try-parse-hex`, but returns a 0 instead of nil. Useful when passing return values into numeric operations.
(parse-int dec-str)
Parses dec-str
to the positive integer it represents
Parses `dec-str` to the positive integer it represents
(parse-int-or-zero int-str)
Like try-parse-int
, but returns a 0 instead of nil.
Useful when passing return values into numeric operations.
Like `try-parse-int`, but returns a 0 instead of nil. Useful when passing return values into numeric operations.
(parse-octal octal-str)
Parse octal-str
to the positive integer it represents in octal
Parse `octal-str` to the positive integer it represents in octal
(parse-octal-or-zero octal-str)
Like try-parse-octal
, but returns a 0 instead of nil.
Useful when passing return values into numeric operations.
Like `try-parse-octal`, but returns a 0 instead of nil. Useful when passing return values into numeric operations.
(parse-radix int-str radix)
Convert int-str
to the positive integer it represents w.r.t. the radix
e.g. (parse-radix "10010" 2) would return 18
Convert `int-str` to the positive integer it represents w.r.t. the `radix` e.g. (parse-radix "10010" 2) would return 18
(parse-radix-or-zero int-str radix)
Like try-parse-radix
, but returns a 0 instead of nil.
Useful when passing return values into numeric operations.
Like `try-parse-radix`, but returns a 0 instead of nil. Useful when passing return values into numeric operations.
(parse-uuid uuid-str)
Parse uuid-str
to the UUID it represents
Parse `uuid-str` to the UUID it represents
Like parse-binary
, but returns nil for invalid input.
Like `parse-binary`, but returns nil for invalid input.
Like parse-binary
, but returns nil for invalid input.
Like `parse-binary`, but returns nil for invalid input.
(try-parse-double double-string)
Like parse-double
, but returns double-string for doubles, and nil for invalid input
Like `parse-double`, but returns double-string for doubles, and nil for invalid input
(try-parse-float float-string)
Like parse-float
, but returns float-string for floats, and nil for invalid input
Like `parse-float`, but returns float-string for floats, and nil for invalid input
(try-parse-guid u)
Like parse-guid
, but returns u
if it's already a GUID, or nil for invalid inputs.
Like `parse-guid`, but returns `u` if it's already a GUID, or nil for invalid inputs.
Like parse-hex
, but returns nil for invalid input.
Like `parse-hex`, but returns nil for invalid input.
Like parse-int
, but returns nil for invalid input.
Like `parse-int`, but returns nil for invalid input.
Like parse-octal
, but returns nil for invalid input.
Like `parse-octal`, but returns nil for invalid input.
Like parse-radix
, but returns nil for invalid input.
Like `parse-radix`, but returns nil for invalid input.
(try-parse-uuid u)
Like parse-uuid
, but returns u
if it's already a UUID, or nil for invalid inputs.
Like `parse-uuid`, but returns `u` if it's already a UUID, or nil for invalid inputs.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close