Reputation: 1401
I am having set of records like this
Affiliate.create(email: '[email protected]', name: 'xxx', mobile: '99999999 ', company_name: 'Exxample', approved:true, city_currently_residing_in: 'Indore', affiliate_occupation_id: AffiliateOccupation.find_by(name: 'Chartered Accountant (CA)').id, user_id: User.find_by(email: '[email protected]').id
How do I replace
Affiliate.create(email: 'whateverstring',
with whitespace.
I tried
%s/Affiliate.create(email: '[a-z]',/
Upvotes: 1
Views: 84
Reputation: 195269
if you are in vim, you don't need do substitution, do it in this way:
g/^Affiliate\.create(email:/norm! 0df,
the above line will delete the Affili....
part, not replace them with same number of spaces. If you want to replace them into whitespaces. (leave that part as empty, but not removing):
g/^Affiliate\.create(email:/norm! 0vf,r (space at the end)
Upvotes: 1
Reputation: 198526
:%s/Affiliate\.create(email: '[^']\+', /\=substitute(submatch(0), '.', ' ', 'g')/
will substitute with the equivalent amount of whitespace. If you need fixed amount of whitespace, Avinash Raj's or anubhava's answers are correct.
Upvotes: 1
Reputation: 174864
You could try the below code,
:%s/Affiliate\.create(email: '[^']*',/ /
Upvotes: 0