core :: Text :: get_numhead
self
if presentReturns "" otherwise
intrude import core::fixed_ints_text
assert "0xFEFF".get_numhead == "0x"
assert "0b01001".get_numhead == "0b"
assert "0o872".get_numhead == "0o"
assert "98".get_numhead == ""
# Gets the numeric head of `self` if present
# Returns "" otherwise
#
# intrude import core::fixed_ints_text
# assert "0xFEFF".get_numhead == "0x"
# assert "0b01001".get_numhead == "0b"
# assert "0o872".get_numhead == "0o"
# assert "98".get_numhead == ""
private fun get_numhead: Text do
if self.length < 2 then return ""
var c = self[0]
if c != '0' then return ""
c = self[1]
if c == 'x' or c == 'b' or c == 'o' or
c == 'X' or c == 'B' or c == 'O' then return substring(0, 2)
return ""
end
lib/core/text/fixed_ints_text.nit:158,2--174,4