I am trying to change one of the legacy code that declares everything in arrays to a collection. I’d like to do a simple search-and-replace using regular expressions and I was wondering if anyone could help me out.
For example, if arrays are declared this way:
array[0] = “1”;
array[1] = “2”;
array[2] = “3”;
array[3] = “4”;
array[4] = “5”;
array[5] = “6”;
array[6] = “7”;
array[7] = “8”;
I would like to grep array[{number}] and replace it with something like list.add(
The regular expression that I am trying to use is array[[0-9]+] but I am getting a syntax error. If anyone could give a helping hand, I would really appreciate it. Thanks a lot.
Try escaping the outer square brackets: