Find and Replace in Files

Replace the specified text in a list of files with new text.
ダウンロード: 2.4K
更新 2016/9/1

ライセンスの表示

This utility will replace all string matches in the target files with a given string. This is similar to 'Replace all' in the editor, except that it can be used programmatically and on multiple files.
For instance, to replace all occurrences of 'abs' with 'mag':

>> find_and_replace('my_file.m', 'abs', 'mag')

Both the "match" and "replace" inputs can be regular expressions. For instance, we can replace all calls to sqrt(...) with my_sqrt(...), keeping the function's argument by using regular expressions.

>> find_and_replace(file_names, 'sqrt\((.*?)\)', 'my_sqrt\($1\)');

For more examples:

>> help find_and_replace;

Some knowledge of regular expressions is helpful, but not required, to use this tool. See 'Regular Expressions' in MATLAB's documentation.

引用

Tucker McClure (2024). Find and Replace in Files (https://www.mathworks.com/matlabcentral/fileexchange/42877-find-and-replace-in-files), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2013a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersEnvironment and Settings についてさらに検索
タグ タグを追加
謝辞

ヒントを与えたファイル: strrepfile

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.1.0.1

Updated license

1.1.0.0

Updated trademarks.

1.0.0.0