且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在RAD Studio中使用正则表达式替换文本

更新时间:2023-02-23 14:13:42

使用{}对表达式而不是()和\\ \\ 1在替换文本中:



查找表达式: F \(G \({。+} \)\) / code>;替换表达式: H(\0)


I want to replace for example F(G(X,Y)); with H(X,Y); In RAD Studio IDE.

The regex I use is:

Find Expression: F\(G\((.+)\)\); Replace Expression: H($1)

The result is not as I expect:

Result: H($1)

It seems the RAD Studio does not recognize the $1 as the contents between two parentheses.
Anybody have an idea?
Thanks

Use {} to group the expression rather than () and \1 in the replacement text:

Find Expression: F\(G\({.+}\)\); Replace Expression: H(\0)