Simple regular expression question (search in VS2008)
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:
array\[[0-9]+\]
I believe you will have to escape your square brackets, as they would normally signify an option group. Use the \ to escape each of your outer square brackets
精彩评论