REGEX用$ test [“index”]替换php4样式数组$ test [index]

时间:2016-07-06 07:08:57

标签: php arrays regex eclipse

我需要一些帮助来替换没有双引号的数组索引。

我需要在eclipse中执行此操作,并且目前有以下REGEX来查找数组,但是,我的替换不是正确替换值,而是截断索引中改变索引值的文本。

示例:

echo "This is an example" . $testArray[testIndex];

当我在eclipse的find字段中输入REGEX时,以下正则表达式突出显示[testIndex]:

\[[^"$](.*?)[^"$]\]

但是,当我使用以下REGEX替换找到的值时,它会截断索引。

\["$1"\]

更换后,会发生以下情况。

echo "This is an example" . $testArray[testIndex];

变为

echo "This is an example" . $testArray["estInde"];

任何帮助将不胜感激。

干杯,

Vish。

1 个答案:

答案 0 :(得分:0)

试试这个正则表达式:

Uncaught TypeError: Cannot read property 'on' of undefined

此处的在线示例:https://regex101.com/r/bY9wL2/1