Regex Aptana Studio中的正则表达式查找和替换
我正在尝试在aptana中查找和替换许多php文件。为了简化我的工作,我做了一个正则表达式,它可以找到我需要的东西,但替换不起作用 这正是我想要做的:Regex Aptana Studio中的正则表达式查找和替换,regex,replace,ide,aptana,Regex,Replace,Ide,Aptana,我正在尝试在aptana中查找和替换许多php文件。为了简化我的工作,我做了一个正则表达式,它可以找到我需要的东西,但替换不起作用 这正是我想要做的: Replace _e("This is a sentence."); with _e("This is a sentenct.","mydomain"); 这是我用于查找匹配项的正则表达式: \_e\(\"([\a-z-]+)\"\) --> it works 这是我用来替换匹配项的正则表达式 \_e\(\"([\a-z-]+
Replace _e("This is a sentence.");
with _e("This is a sentenct.","mydomain");
这是我用于查找匹配项的正则表达式:
\_e\(\"([\a-z-]+)\"\) --> it works
这是我用来替换匹配项的正则表达式
\_e\(\"([\a-z-]+)\",\"mydomain\") --> It does not work,
这就是它所取代的:
_e("([-z-]+)","mydomain"); --> bad result
编辑:此外,我需要我的正则表达式来查找特殊字符,如ă、ș您似乎还不太了解替换字符串的工作原理。替换字符串是内部没有正则表达式符号的普通字符串。文本字符串的唯一区别在于,可以从搜索模式中添加反向引用 例如:
search: (_e\("[^"]*")\)
replace: $1,"mydomain")
图案详情:
( # open the capture group 1
_e # literal: _e
\(" # literal: (" (literal parenthesis must be escaped since it has a
# special meaning in a pattern (to define groups))
[^"]* # all that is not a ", zero or more times
" # literal "
) # close the capture group 1
\) # literal closing parenthesis
替换字符串中的$1
是一个反向引用,引用搜索模式中捕获组1的内容。请注意,右括号没有转义,因为它在替换字符串中没有特殊意义
(不要忘记选中“搜索/替换”对话框中的.*复选框)