Sublime Forum

Regex find and replace causes random letter case change

#1

Sometimes when I run a regex find and replace I get random letters changing case. For example I ran this regex:

(\w+\.\w+\.\w+) = class \w+ extends (\w+)

and this replace:

class $1 extends $2

And it converts:

Project.Models.Opinion = class Opinion extends Project.Model

to

Class Project.MOdeLs.opinion exTenDs project.Model

I’m running version 2.0.1 build 2217 on linux.

0 Likes

#2

Try unsetting the “Preserve Case” option in your find panel.

0 Likes

#3

Thanks that works! Do you know why I was getting such odd results with preserve case on? Also, what does preserve case specifically does? The case is still preserved with it off so i’m not sure what effect it has.

0 Likes

#4

No, I actually have no idea how it works… I think it’s mostly for when you do a case-insensitive find+replace, so if you search for foo and replace with bar, it’ll change foo to bar and Foo to Bar or something.

0 Likes