Giter Club home page Giter Club logo

change's Introduction

change

Releases

Python script to change the contents or names of a set of files using regular expressions.

I find it handy for changing variable names and version numbers on a project.

To use it you specify the old pattern, the new pattern and the list of files.

The patterns are in python regular expression format which makes it easy to change text that contains things like forward slashes.

Here is a detailed example thats shows how to change foo to bar in several files and stores the results in the local tmp directory tree. To see other examples look at test/test.sh.

    $ tree example/
      example
      ├── foo-bar.txt
      └── foo.txt
      
      0 directories, 2 files

    $ cat foo.txt
    foo foo

    $ cat foo-bar.txt
    foo foo
    
    $ change -p tmp/ foo bar foo.txt foo-bar.txt
    
    $ tree tmp
      tmp
      ├── bar-bar.txt
      └── bar.txt
    
      0 directories, 2 files

If you want to substitute characters that used in regular expressions like '.', you must escape it with a backslash '\.'.

If you want to only replace words use '\b' like this '\bfoobarspam\b'.

For other options see the documentation for Python regular expressions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.