In a text editor, I want to replace a given word with the number of the line number on which this word is found. Is this is possible with Regex?
Because you didn't specify which text editor, in vim it would be:
:%s/searched_word/\=printf('%-4d', line('.'))/g (read more)
:%s/searched_word/\=printf('%-4d', line('.'))/g
But as somebody mentioned it's not a question for SO but rather Super User ;)