your-tools / ruplacer

Find and replace text in source files
BSD 3-Clause "New" or "Revised" License
426 stars 25 forks source link

Use capturing group next to literal #98

Open Masynchin opened 2 years ago

Masynchin commented 2 years ago

Proposed tag: question.

I want to make all class {Name}Test to be internal class {Name}Test, so I try to run:

ruplacer 'class (\w+)Test' 'internal class $1Test'

But it doesn't work as expected. I avoided it with

ruplacer 'class (\w+)(Test)' 'internal class $1$2'

But how can solve my issue without adding second capturing group?

Masynchin commented 2 years ago

@dmerejkowsky I am looking for help!

djmattyg007 commented 1 year ago

Try putting a question mark after the + to make it non-greedy.