Digital Ninja
Digital Ninja

Reputation: 3741

Using matched patterns in replace

I don't see the Sublime regex documentation saying anything about how to use matched patterns in the replace function. I tried to use the PHP/htaccess format of $0 (and $1 just in case the indexes start with 1), but no luck.

What I'm trying to do, is go through all my methods, and make static methods begin with an uppercase letter. So I would like to change all calls to Foo::bar() (PHP syntax) into Foo::Bar(). So even if I knew how to use the matched pattern (in this case b), is there a way to make it uppercase in the replace field?

Upvotes: 2

Views: 42

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627128

These operators are described in the Boost regex library reference:

\u     Causes the next character to be outputted, to be output in upper case.

So, you may use \u uppercase operator in the replacement pattern to make the first character after it uppercase.

Search: ::(\w+\(\))
Replace: ::\u$1

enter image description here

Upvotes: 2

Related Questions