带有正则表达式的 Sublime Bug

Sublime Bug with Regular Expressions

我正在尝试进行出色的正则表达式搜索并替换为反向引用。这是我的数据集:

if(requestType.endsWith("CompleteMulti")) {
if(requestType.endsWith("CompletePartial")) {
if(requestType.endsWith("Unfulfillable")) {

当我运行正则表达式时:

^.+"(\w+)".+$

替换语句:


我得到以下输出:

completemuLti
completepaRtial
unfulfillaBle

如您所见,字母的大小写一团糟。 我使用的是版本 2.0.2,内部版本 2221

这是一个已知问题吗?一些 google 搜索没有找到任何数据。如果有人知道解决方法,请告诉我。

在执行您的 "replace all" 之前,取消选择选项 "preserve case" (ALT+A)

"Preserve case" 将保留 之前那个位置的字符 的大小写。快速演示:

if(requestType.endsWith("CompleteMulti")) {
if(requestType.endsWith("CompletePartial")) {
if(requestType.endsWith("Unfulfillable")) {
completemuLti
completepaRtial
unfulfillaBle

          ^ only this character is left in upper case

再举个例子。这次我们将 "sublime" 替换为 "bananas",使用不区分大小写的正则表达式并选择 "preserve case":

之前:

SUblime
suBLime
sublIME

之后:

BAnanas
baNAnas
banaNAS

作为对 IcedD​​ante 评论的回应,我可以想到一个用例,其中它是所需的行为(尽管它可能是人为的)..想象一下您要发送给多所大学的一封信:

Dear University of Blahtown,

I am writing to enquire about your Applied Biology 101 course, as I understand you're the leading school in the field of biology. I have always had a keen interest in the field of biological reseach and so this course, Applied Biology 101, is of particular interest.

然后你还想查询地理课程,你可以find/replace"biolog"和"geograph",保持大小写:

Dear University of Blahtown,

I am writing to enquire about your Applied Geography 101 course, as I understand you're the leading school in the field of geography. I have always had a keen interest in the field of geographical reseach and so this course, Applied Geography 101, is of particular interest.

我知道这很做作。

注意 - 我试过在文档中查找对此的引用,但找不到任何确定的内容...