如何与例如分割QUOT只有十字符的字符串; 12345 * 45688"成阵列 [英] How to split a string of only ten characters e.g."12345*45688" into an array

查看:229
本文介绍了如何与例如分割QUOT只有十字符的字符串; 12345 * 45688"成阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在那里你可以输入值到一个编辑框,一个简单的计算器。我需要的字符串分割成多个阵列取决于有多少* + - /有在例如总和

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 for instance

我有22 + 22 *​​ 22-22 / 22我要打破这种分为五个不同的阵列,因为有数字的五个不同的群体。再后来我要ARRAY1添加到阵列中两个乘以ARRAY3和减去由array4和除以阵列5。

I have 22+22*22-22/22 I want to break that into five different arrays because there are five different groups of numbers. Then later I am going to add array1 to array two multiply that by array3 and subtract that by array4 and divide that by array 5.

推荐答案

如果你想读这样的事情,特别是如果你要评估的数学EX pressions,你需要的不仅仅是一个阵列的拆分以上;你需要一个真正的解析器。这样做是正确需要一点点编译原理的。我建议你​​看看让我们构建一个编译器,即涵盖了你会教程需要了解的前pression解析(多一点,因为他实际上构建一个简单的编译器),并可以很容易理解。所有的例子都在Turbo Pascal的,所以它应该是很容易的德尔福codeR阅读。

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.

这篇关于如何与例如分割QUOT只有十字符的字符串; 12345 * 45688"成阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆