Home > Software engineering >  Ruby find and replace string
Ruby find and replace string

Time:12-01

Can anyone help me to find and replace the string

if (!project.hasProperty('cdvVersionCode')) {
        cdvVersionCode = null
}
if (!project.hasProperty('cdvBuildMultipleApks')) {
    cdvBuildMultipleApks = null
}

in the above string I need to find

cdvVersionCode = null

and replace as below

cdvVersionCode = 300

CodePudding user response:

In Ruby , the []= method is also known as slice. Here is an example:

str = "qwertyuiop"
str["rty"] = "zxc"
p str # => "qwezxcuiop"
  •  Tags:  
  • ruby
  • Related