M-x query-replace-regexp,
\(sea\)
RET
\,(progn (or count (setq count 1))(setq count (1+ count))(concat "(" (number-to-string count) ")" \1))
RET

;;;;;;;;;;;;

\,EXPR

evaluates the expression and the takes the result for replacement.


Andreas

--
https://launchpad.net/python-mode
https://launchpad.net/s-x-emacs-werkstatt/



Thank you very much Teemu and Andreas!
Regards,
Kashyap