Atom regex find and use value as replace value


#1

Hi, how can i add extra string on the code? i want to achieve something like this

["zip_code"=>"29078", "city"=>"Lugoff", "county" => "Kershaw"],

these are the codes,

["zip_code"=>"29078", "city"=>"Lugoff", "Kershaw"],
["zip_code"=>"29079", "city"=>"Lydia", "Darlington"],
["zip_code"=>"29080", "city"=>"Lynchburg", "Lee"],

i use this regex to select the "Lugoff", ", now how can i add the "county"=> ??

“([a-z])+”, "


#2

In the replace field, put "$1", "county"=>.


#3

it’s not working, it just replaces the text literally as $i


#4

The number 1.


#5

yes, i meant’ $1 sorry,


#6


#7

Why did you delete the original regular expression? You can’t have a variable in the replace string with no capture group. If you find "([a-z])+", " and replace it with "$1", "county"=>, the capture group value will be retained.