0

I am newbie to solidity. I am trying to split a string at into different based on '?' appearing. For example

test/?stat=true  -----> test/  and stat=true
test/?stat=true?newstat=false  -----> test/    stat=true and  newstat=false

how this can be done. I tried using string utils library but it gives me a bunch of errors

https://github.com/Arachnid/solidity-stringutils

I tried splitting like this as an example (sample code)

// SPDX-License-Identifier: MIT
import "github.com/Arachnid/solidity-stringutils/src/strings.sol";

contract Contract { using strings for *;

var s = "foo bar baz".toSlice();
var foo = s.split(" ".toSlice());

}

I am getting the following error

from solidity:
ParserError: Function, variable, struct or modifier declaration expected.
 --> trial.sol:7:5:
  |
7 |     var s = "foo bar baz".toSlice();
  |     ^^^
imhans4305
  • 101
  • 2

1 Answers1

1

The var keyword was deprecated in Solidity 0.4.20 (see release notes).

This previous answer should help with what you want to do: How can I slice bytes, strings, and arrays in Solidity?

Richard Horrocks
  • 37,835
  • 13
  • 87
  • 144