objective-cregexxcodemethodsreplace

Use regex for change arguments count


I am new in using regex.

I am trying to change arguments count in my method. In fact I need to cut second argument and rename it.

I've read this article:Using Regular Expressions to replace text in XCode. And decided to use my "new knowledge". But something went wrong.

So: hear is the "regex" which I've written.

enter image description here

Source string:

[self.delegate filteredTasksListContainer:self addItemWithType:type];

Result string:

[self.delegate filteredTasksListContainer_addItem:1];

Needed result string:

 [self.delegate filteredTasksListContainer_addItem:self];

Solution

  • It looks pretty good for me, but I would try tu use $1 instead of \1.

    \1 is usually used in the regex itself, rarely in the replacement pattern.