我一直在使用正则表达式(在 textmate 的查找和替换工具中)将我收到的值表重新格式化为 PHP 数组。
我已经完成了大部分工作——但在最后的改变中挣扎。
当前状态:
$subSectors[1] = 'Crop & Animal Production, Hunting & Related Service Activities'; [1]
$subSectors[2] = 'Forestry & Logging'; [1]
我正在寻找批量替换(100 行),以便最终字符 [\d{0-3}] 移动为主数组键。
所以上面两行会变成:
$subSectors[1][1] = 'Crop & Animal Production, Hunting & Related Service Activities';
$subSectors[1][2] = 'Forestry & Logging';
行尾括号值的长度可以是 1-3 位。
我可以使用以下方法匹配括号中的值:
\[\d{0,3}]$
但是不知如何构造替换字符串。