RegEx用于动态表达式替换

时间:2015-11-10 16:33:26

标签: regular-language

对于以下情况我需要两个正则表达式:

1。 替换这个

lr_start_transaction(lr_eval_string("{scriptid}_0010_123-A1-a_text-or-numbers"));

用这个

lr_end_transaction("001_0010_123-A1-a_text-or-numbers",LR_AUTO);

2。替换这个

lr_end_transaction(lr_eval_string("{scriptid}_0010_123-A1-a_text-or-numbers"),LR_AUTO);

用这个

Dim TempArray() As Integer

撇号之间的部分是动态的。

我使用Notepad ++编辑代码。

有人可以帮我吗???

1 个答案:

答案 0 :(得分:0)

您能否只搜索DEMO

(\(".*?)(_.*")

并将其替换为:

transaction(lr_eval_string("{scripted}\2)

说明:

(\(".*?) // look for (" in a non-greedy way (capture in \1)
(_.*")   // look for an underscore up to the next quote (capture in \2)


transaction(lr_eval_string("{scripted}\2)
// replace text, put back the capture group 2, then a closing parenthesis