简体   繁体   English

跨文件夹中的所有文件转换正则表达式

[英]Convert reg-ex across all files in folder

I am a novice with reg-ex and would like to know how to convert the following in every c file in a folder.我是 reg-ex 的新手,想知道如何在文件夹中的每个 c 文件中转换以下内容。

#Before
TEST_RESULTS *setAll = FIXED(TEST_VALUES_ONE);

#After
TEST_RESULTS *setAll = FIXED_SET(setAll, TEST_VALUES_ONE);

The only constant in this is FIXED , whereas the others are variables and will have different names throughout the files.其中唯一的常量是FIXED ,而其他常量是变量,并且在整个文件中具有不同的名称。 One other thing some of the files with this expression cover two lines.另一件事是一些带有这个表达式的文件包含两行。 Does that need to be different I guess?我猜这需要不同吗? eg例如

TEST_RESULTS_TWO *setAllTwo =
            FIXED(TEST_VALUES_ONE));

Preferably carried out in python/perl最好在 python/perl 中进行

perl -pi.bak -e's/FIXED\(/FIXED_SET(setAll, /g' <files>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM