简体   繁体   English

中缀到后缀的正则表达式

[英]Regular expression for infix to postfix

I came across following line while going through code that converts infix expression to postfix. 我在浏览将中缀表达式转换为后缀的代码时遇到了以下行。

string pattern = @"(?<=[^\\\\.a-zA-Z\\\\d])|(?=[^\\\\.a-zA-Z\\\\d])"

Could not quite get what "\\\\" in above regular expression is worth while converting something like ((a+(b*(f/c)))-e) to abfc/*+e- 在将((a+(b*(f/c)))-e) to abfc/*+e-东西时,无法完全得到上述正则表达式中的“\\\\”值

When the value gets assigned to the string, it will become \\. 当值被赋值给字符串时,它将变为\\. which means you are literally looking for a . 这意味着你真的在寻找一个.

In regular expression . 在正则表达式中. matches any character, where as here, \\. 匹配任何字符,在这里, \\. will match a . 会匹配一个. character literally. 从字面上看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM