How to split a string of only ten characters e.g.“12345*45688” into an array

后端 未结 4 441
梦毁少年i
梦毁少年i 2021-01-13 05:41

I\'m making a simple calculator where you type values into an edit box. I need to split the string into a number of arrays depending on how many *+-/ there are in the sum fo

4条回答
  •  失恋的感觉
    2021-01-13 06:30

    If you want to read something like that, especially if you want to evaluate mathematical expressions, you need more than just an array-splitter; you need a real parser. Doing it right requires a bit of compiler theory. I'd recommend you take a look at Let's Build A Compiler, a tutorial that covers everything you'll need to know about expression parsing (and a bit more, since he's actually building a simple compiler) and makes it easy to understand. All examples are in Turbo Pascal, so it should be easy for a Delphi coder to read.

提交回复
热议问题