zoukankan      html  css  js  c++  java
  • 第4月第23天 文本替换

    1.python

    http://blog.chinaunix.net/uid-25602770-id-4009387.html

    2.ruby

    https://my.oschina.net/moluyingxing/blog/192248

    Dir.glob('**/*').each do |file|
      next unless /.m$/ =~ file or /.h$/ =~ file  # Only Objective C code.
      next if /^ZergSupport/TestSupport/GTM// =~ file  # Skip GTM code.
      next if /^ZergSupport/TestSupport/OCMock// =~ file  # Skip OCMock code.
      
      contents = File.read file
      
      # eat whitespace at the end of lines
      contents.gsub! /[ 	]+$/, ""
      # tabs are 2 spaces
      contents.gsub! "	", "  "
      
      # force -(type)method instead of - (type) method
      contents.gsub! /-s*(([^(]*))s*(w)/, "-(\1)\2"
      contents.gsub! /+s*(([^(]*))s*(w)/, "+(\1)\2"
      
      # force methodName:(type)argument instead of methodName: (type)argument
      contents.gsub! /(w+):[ 	]*(/, "\1:("
    
      # license
      contents.gsub! '__MyCompanyName__', 'Zergling.Net'
      contents.gsub! /^//  Copyright.*Zergling.Net. .*.$/,
                     "//  Copyright Zergling.Net. Licensed under the MIT license."
      
      File.open(file, 'w') { |f| f.write contents }
    end
  • 相关阅读:
    FastAdmin 提示框 toastr 改变文字
    FastAdmin 将会员模块升级为基础模块的升级指导
    随笔
    随笔
    c++11 lambda(了解)
    c++11 类型推断
    boost::archive::text_oarchive
    std::ostringstream
    随笔
    随笔1
  • 原文地址:https://www.cnblogs.com/javastart/p/6344653.html
Copyright © 2011-2022 走看看