0

I am trying to make this regex work, need to find every occurance of # character in a text, and replace every next occurance with different word, like: word1, word2, word3...tried this

(^.*#.*$)

replace with

(word1)
(word2)
(word3)

or

\1word1\2word2\3word3

it always replace it with all the words.

Jim8645
  • 181
  • 3
  • 15
  • 1
    This [question](http://stackoverflow.com/questions/4213800/is-there-something-like-a-counter-variable-in-regular-expression-replace) asked about a similar thing. With a solution in perl. Basically, using a variable counter from the programming language. Regex doesn't seem to have a flag for a counter of the match. – LukStorms Jun 26 '16 at 11:48
  • Is the number of these words defined? – logi-kal Jul 13 '16 at 18:46
  • First matching word should be replaced with first word in replace-list. – Jim8645 Jul 15 '16 at 10:04
  • Yes, but we do or we don't know the size of the replace-list? And at the end of the list the replacements shoud re-start from the begin? – logi-kal Jul 15 '16 at 10:56
  • And -sorry but it's not clear- do you want to replace only the `#` character or the whole line in which `#` appears? – logi-kal Jul 15 '16 at 11:33

0 Answers0