【发布时间】:2015-01-15 08:22:58
【问题描述】:
在我的文本编辑器(phpStorm、notepad++、jedit 等)中,我有如下字符串:
.... $this->request_json['store-user-id'] .....
.... $this->request_json['deviceID'] ....
我需要将它们替换为:
$this->request->store_user_id
$this->request->device_id
即
search: \-\>request_json\[\"([\w_\-]+)\"\]
replace: ->request->$1
但是:我需要额外的内联替换“-”->“_”,转换为小写并在每个大写字母前加上“_”。
这可能使用 perl 风格的正则表达式吗?也许是递归的?
【问题讨论】:
-
在 Notepad++ 6.0 或更高版本中,您可以使用“PCRE(Perl 兼容正则表达式)搜索/替换”(来源:sourceforge.net/apps/mediawiki/notepad-plus/…)。所以你可以使用像
(. )([A-z])(.+)这样的正则表达式和像\1\U\2\3这样的替换参数 -
谢谢。我在哪里可以找到有关这些有趣的替换参数的信息? notepad++ 帮助中没有任何内容
-
请查看此链接:letconex.blogspot.fr/2013/06/…。见
9. Substitutions
标签: php regex notepad++ phpstorm jedit