169 похожих чатов

16 ответов

13 просмотров

Good question. I don't see why not but you should be able to quickly test this out.

yes you just cast it to bytes and work with the bytes themselves, then back to string

Steve-ANT Автор вопроса
Steve ANT
That'll be hell expensive, there should be a direc...

Shouldnt be gas heavy to type cast to bytes and back to string no?

Steve-ANT Автор вопроса
Flagrant
Shouldnt be gas heavy to type cast to bytes and ba...

exactly my thought, it might be pretty expensive operation.

Steve ANT
That'll be hell expensive, there should be a direc...

function substring(string str, uint startIndex, uint endIndex) constant returns (string) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); }

Steve ANT
That'll be hell expensive, there should be a direc...

not super expensive, maybe a few thousand gas. There's no other way to manipulate strings in solidity that I know of

Steve-ANT Автор вопроса
Steve ANT
solidity is a big oof for strings, I'll try to est...

yeah I just ran a test, was like 5k gas above the base tx cost to return a 3 character substring from a 20 or so character one

Похожие вопросы

Обсуждают сегодня

А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, стандартный ;вызов процедуры ;option casemap:no...
Егор Анелькин
1
почому оно не работает?
Vi Chapmann Chapmann
19
Так а кто может спарсить всех участников чата? Идишники
Magic
18
Есть вопрос: допустим есть железка с каким-то интерфейсом(допустим usb), но как по этому интерфейсу железкой управлять неизвестно, прог нету, а управлять очень хочется надо. К...
Mixail Frolov
15
а как ловят такое ghci> res <- getPos2 urlt 0 (alist !! 0) 200 ghci> res SearchAtom (Search "www.google.com" "/search?q=" "Haskell") "haskell.org" (SearchTS [(2024-05-06 07:...
Fedor
14
короче сгенерила мне эта штука код на ассемблере: struc string val { common local .value dq .value .value: if ~val eq db val end if db 0 } fo...
Vi Chapmann Chapmann
12
Карта сайта