Reputation: 503
I am trying to match (a) and replace (b) the following occurrences:
array[0] -> atoi(array[0])
array[1] -> atoi(array[1])
...
array[i+1] -> atoi(array[i+1])
and so on...
(a) I am unable to match anything with the following expression array\\[(.\*?)\\]
, array\\[.\*?\\]
, or array\\[*\\]
I am able to match single character occurrences between the brackets with array\\[.\\]
and additionally also segments with multiples matches on a single line with array\\[.*\\]
(b) After a working match I figure s/"MATCHING REGEX"/atoi(array\[\1\])/g
should work, however attempting that with array\\[.\\]
resulted in atoi(array[])
Upvotes: 2
Views: 10303
Reputation: 631
Well you don't really say what RegEx engine you are using but if I had to guess it may be that this particular engine doesn't like the "non-greedy" qualifier. So let's try the regex eleminating the non-greedy qualifier and using a character class of "not closing square bracket" in place of the non-greedy ".*?". Try this instead:
array[([^]]*)]
Upvotes: 0