elect
05/11/2021, 3:00 PMString
(~15k chars) the integer on the right of the following sentence?
.. ,"number":12,"..I'd
indexOf
, then extract the next 4 chars, drop at the first comma and convertYoussef Shoaib [MOD]
05/11/2021, 6:33 PMindexOf
is possibly the best approach hereelect
05/11/2021, 6:35 PMYoussef Shoaib [MOD]
05/11/2021, 6:42 PMnkiesel
05/11/2021, 8:31 PMYoussef Shoaib [MOD]
05/11/2021, 8:36 PMnumber
field, then using normal string indexing should suffice.Nir
05/11/2021, 9:01 PMPetter Måhlén
05/12/2021, 6:27 AMelect
05/12/2021, 7:26 AMMichael Böiers
05/12/2021, 12:57 PMnkiesel
05/13/2021, 12:22 AMvar i = 0; while (idx < size) { val d = s[idx++].digitToIntOrNull() ?: break; i = 10 * i + d }
Note: this assumes no leading [-+]
nkiesel
05/13/2021, 12:58 AMelect
05/13/2021, 8:18 AM