0

Is there a counter that regex 'uses' that can be out put?

For instance, if I have this text:

(),
(),
(),
()

I want to use a regex pattern to add the count to the output for each match. so in this case the desired result would be:

(1),
(2),
(3),
(4)

Surely there is an internal counter, but can it be used as output?

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
roberthuttinger
  • 1,172
  • 1
  • 17
  • 31
  • @roberthuttinger Does the programming language matter? Or does it have to use grep? – Larry Battle Aug 16 '12 at 14:42
  • well from an educational standpoint, no. However if this does exist in GREP for bbedit, I would love to have it in my arsenal! I know that one can use preg_match and the $matches array, etc. with PHP – roberthuttinger Aug 16 '12 at 15:00

0 Answers0