Page 1 of 1

Some problem with replace()

Posted: Wed Mar 19, 2014 4:33 pm
by azure_glass
Hi!

I have some problem with replace()

pattern(perl regex): (1,2,3,4)

code
selectString(matches[2], 1)
replace(matches[2].." [GL]")

Text from mud:

5, 6, 1, 8, 2

is

5, 6, 1 [GL], 8, 2

should be:

5, 6, 1 [GL], 8, 2 [GL]


What I'm doing wrong?

Re: Some problem with replace()

Posted: Wed Mar 19, 2014 6:38 pm
by Jor'Mox
In general, triggers fire once per line. So that is looking for a single instance of 1, 2, 3, or 4. It found one, did what it was supposed to do, and then was never looked at again. You need to check "match all"... and then I believe it will be returned as a series of matches... so matches[1] and [2] will be for your first match, then [3] and [4] are for the second, and so on.