exprv4:reference:methods:string_parsing_methods




String Parsing Methods

String parsing methods convert string values into numbers or boolean-style numbers.

Invalid input raises a runtime error.


parse_num()

Parses decimal numeric text.

Item Description
Syntax `string.parse_num()`
Arguments none
Returns number

Example:

'123.45'.parse_num();
'-10'.parse_num();

parse_hex()

Parses hexadecimal text.

Item Description
Syntax `string.parse_hex()`
Arguments none
Returns number

Example:

'FF'.parse_hex();       // 255
'0x10'.parse_hex();     // 16

parse_bin()

Parses binary text.

Item Description
Syntax `string.parse_bin()`
Arguments none
Returns number

Example:

'1010'.parse_bin();     // 10
'0b1010'.parse_bin();

parse_bool()

Parses boolean text.

Item Description
Syntax `string.parse_bool()`
Arguments none
Returns boolean-style number

Accepted values are `true`, `false`, `1`, and `0`.

Example:

'true'.parse_bool();    // true
'0'.parse_bool();       // false

Previous: String Slice Methods

Next: String Formatting Methods

exprv4/reference/methods/string_parsing_methods.txt · Last modified: by 127.0.0.1

Page Tools