1
我有一个vb.net正则表达式,我正用它来识别简单的z + x
总和中的运算符。如何使用词法分析来识别给定表达式中的关键字?vb.net在简单的词法分析器中识别关键字
我当前的代码:
Dim input As String = txtInput.Text
Dim symbol As String = "([-+*/])"
Dim substrings() As String = Regex.Split(input, symbol)
For Each match As String In substrings
lstOutput.Items.Add(match) '<-- Do I need to add a string here to identify the regular expression?
Next
input: z + x
这就是我想要的输出
z - keyword
+ - operator
x - keyword
感谢罗宾我也没有else if语句可用于输入数字.. –