I'm trying to make a text tokenizer.
Type from this text:

10 meters 192.168.0.1 100 

It should make such an array (approximately):

 [ { type: "units:meters", value: "10" }, { type: "ipaddress", value: "192.168.0.1" }, { type: "number", value: "100" } ] 

I have already made separate parsers for them, but they parse the entire text and give all the matches.

How can I do something so that they are in the correct order and so that they do not overlap each other (for example, so that the parser would not take the beginning and end of the IP address separately as numbers)?

  • Great, and what is the question, what is the problem? - Kromster
  • @Kromster, read the end of the question - NeoKat
  • The end of the question ends with a sign ? . - user207618
  • @Other, oops, I forgot that I ask the question = D - NeoKat
  • We write in Russian, and the rules do not comply. Try a regular schedule or take one character first, check for a possible token, no - take another one, and so on. User207618

1 answer 1

I found a solution:
You can simply search for one parser and delete the passed piece of the string.