注意,最初的 “最小字符数” 子模式和运算符子模式都在捕捉圆括号内进行了指定:\(...\)。
Note that both the initial "minimal number of characters" subpattern and the operator subpattern are specified within capturing parentheses: \(...\).
从设计的角度看,有些其他的选择是有问题的;例如,使用字符串来承载运算符就有可能出现小的输入错误,最终会导致结果不正确。
From a design perspective, some other choices are questionable; for example, the use of Strings to hold the operators opens up the possibility of small typos leading to erroneous results.
第一,通过将其他字符串添加在一起,可以创建新的字符串,具体方法可以使用+运算符,或者干脆使用适当的引号将字符串连在一起。
First, you can create a new string by adding other strings together, either using the + operator or by just sticking strings together using the appropriate quotes.
应用推荐