readNumber static method
Implementation
static num readNumber(UDocCursor cursor) {
final StringBuffer buffer = StringBuffer();
while (!cursor.isEmpty) {
final int byte = cursor.peek;
if (isDigit(byte) || byte == 0x2B || byte == 0x2D || byte == 0x2E || byte == 0x45 || byte == 0x65) {
buffer.writeCharCode(cursor.u8());
continue;
}
break;
}
final String raw = buffer.toString();
final int? asInt = int.tryParse(raw);
if (asInt != null) return asInt;
return double.tryParse(raw) ?? double.tryParse(raw.replaceAll(RegExp(r"[^0-9.\-]"), "")) ?? 0;
}