Replace all with dynamic value


#1

Hi,
I decided to change my translation package in my react native project.
They both of course use different integration syntax.

So my question is: doest the Replace All function in Atom support dynamic stuff in the string to search and replace for ?

Here is my case:

My old package use Translate.keyToTranslate and the new one I18n.t('keyToTranslate') so for the new syntax I need to close the ') after.

So I’m wondering if I can replace all Translate.{0} by I18n.t('{0}') or something like that.


#2

Yes. You just use a capture group. If you put Translate.(keyToTranslate) in the find box and replace it with I18n.t('$1'), the content inside the capture group will be preserved.


#3

Great, just have to find the right regex, thanks !