Repository metrics
- Stars
- (3,516 stars)
- PR merge metrics
- (Avg merge 5h 26m) (19 merged PRs in 30d)
Description
Environment
- TeXstudio: git 4.3.0beta2-23-g0ad5bc7b4
- Qt: 5.15.2
- OS: Debian 11
Expected behavior
在 #2448 中修复了正则表达式中非贪婪匹配的问题,但引入了贪婪匹配的问题。
对于字符串123(666)009(hi),在自定义的宏(Macros)中设置触发条件(Trigger),正则表达式为
\((.+?)\)\t
匹配到的字符串为(hi),这个没有问题。但是将正则表达式改为
\((.+)\)\t
匹配到的字符串依然为(hi),出现了问题,正确的匹配结果应为(666)009(hi)。
这里,通配符+,没有尽可能的匹配最多,反而是匹配最少。
Goole Translate
Fixed non-greedy matching in regular expressions in #2448, but introduced greedy matching.
For the string 123(666)009(hi), set the trigger condition (Trigger) in the custom macro (Macros), the regular expression is
\((.+?)\)\t
The matched string is (hi), which is no problem. But change the regex to
\((.+)\)\t
The matched string is still (hi), there is a problem, the correct matching result should be (666)009(hi).
Here, the wildcard + does not match as much as possible, but matches the least.