Skip to content

Instantly share code, notes, and snippets.

@marks
Forked from franklsf95/test.rb
Created July 10, 2014 00:45
Show Gist options
  • Save marks/fc731726e6f44aaa5813 to your computer and use it in GitHub Desktop.
Save marks/fc731726e6f44aaa5813 to your computer and use it in GitHub Desktop.
# In the following code, the two gsub's have different outcomes.
ver = 9999
str = "\t<key>CFBundleDevelopmentRegion</key>\n\t<string>en</string>\n\t<key>CFBundleVersion</key>\n\t<string>0.1.190</string>\n\t<key>AppID</key>\n\t<string>000000000000000</string>"
puts str.gsub /(CFBundleVersion<\/key>\n\t.*\.).*(<\/string>)/, "#{$1}#{ver}#{$2}"
puts '--------'
puts str.gsub /(CFBundleVersion<\/key>\n\t.*\.).*(<\/string>)/, "#{$1}#{ver}#{$2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment