Reputation: 143
I am trying to get this code to replace one attribute and value but it erases the whole line.
ruby_block "update connection pool" do
block do
fe = Chef::Util::FileEdit.new(servlet_xml_path)
fe.search_file_replace("maxPoolSize=\"[0-9]+\"", "maxPoolSize=\"20\"")
fe.write_file
end
end
The function works if I have a simpler regex like:
fe.search_file_replace("maxPoolSize=", "maxPoolSize2=")
Upvotes: 2
Views: 2305
Reputation: 143
ShellFish provided the answer I was looking for. fe.search_file_replace(/maxPoolSize="[0-9]+"/, 'maxPoolSize="20"')! –
Upvotes: 2