关于在C#中构建简单分析器的问题 [英] A question on building a simple Parser in C#
本文介绍了关于在C#中构建简单分析器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在我要做的是我的程序应该在源文本框中找到它:
Console.WriteLine(
并开始读取字符串之后的字符串直到它找到一个
)
并将字符串存储在变量中,
对于ex
控制台.WriteLine(Hello World)
那么字符串应该包含
Hello World
帮助将不胜感激
Sids123
Now what I want to do is my Program should find this in the source text box:
Console.WriteLine("
And start reading the string just after the " until it finds a
")
And store the string in a variable,
For ex
Console.WriteLine("Hello World")
Then the string should contain
Hello World
Help would be appreciated
Sids123
推荐答案
我不认为这样一个简单而特殊的问题的答案实际上对你有帮助,但如果这真的是你想要的全部,答案就是答案很简单: http://msdn.microsoft.com/en-us/library /system.text.regularexpressions.regex.aspx [ ^ ]。
正则表达式wi将是这样的:
I don't think that the answer to such a simple and particular question will practically help you, but if this is really all you want, the answer is simple: http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^].
The Regular Expression will be something like:
Console\.WriteLine\("(.*)"\)
但是,很难想象你只需要解析这个语句而不需要其他任何东西,所以你需要一个真正的解析器。糟糕的是你没有费心去解释你的最终目标。
这篇关于关于在C#中构建简单分析器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文