Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse tokens into several arrays/lists #101

Closed
abrasat opened this issue Aug 7, 2019 · 1 comment
Closed

Parse tokens into several arrays/lists #101

abrasat opened this issue Aug 7, 2019 · 1 comment

Comments

@abrasat
Copy link

abrasat commented Aug 7, 2019

I am struggling to find a solution to parse tokens into several different arrays/lists.
The string to tokenize/parse looks like this

(x:x1, x:x2, x:x3, y:y1, z:z1, z:z2)

The result should be stored in a node like this:

class Node
{
  List<string> xItems; // contains all items for token x: (x1, x2, x3 in the example above)
  List<string> yItems; // contains all items for token y: (y1 in the example above)
  List<string> zItems; // contains all items for token z: (z1, z2 in the example above)
}

, or more generically, in a node like this

class MoreGenericNode
{
  Dictionary<string,List<string>> items; //the dictionary key is the token (x:, y:, z:, ...)
}

The defined tokens are x:, y:, z:, as well as the comma and the left/right brackets.
Is it possible to get the result information by parsing the input string only once, or is it necessary to parse the string several times, for each token?

@abrasat abrasat changed the title Oarse tokens into several arrays/lists Parse tokens into several arrays/lists Aug 7, 2019
@nblumhardt
Copy link
Member

Hi! Sorry about the slow response. I hope you were able to find a solution - otherwise, Stack Overflow would be a great place to get more info on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants