NB.*stringreplace v replace characters in text string
NB.
NB. form: oldnew stringreplace text
NB.   oldnew is a 2-column boxed matrix of old ,. new
NB.   or a vector of same
stringreplace=: 4 : 0
for_n. _2,\,x do.
  'p q'=. n
  j=. p [EMAIL PROTECTED] y
  if. #j do.
    d=. p-&#q
    k=. (j+(0>.-d)*i.#j)+/i.#q
    select. *d
      case.  1 do. y=. (0 (j+/(#q)+i.d)}1$~#y) # q k}y
      case.  0 do. y=. q k}y
      case. _1 do. y=. q k} (0 (d{."1 k)}1$~(#y)+(#j)*|d) #^:_1 y
    end.
  else.
    y
  end.
end.
)

-- 
View this message in context: 
http://www.nabble.com/tacit-stringreplace-tp20476004s24193p20499217.html
Sent from the J Programming mailing list archive at Nabble.com.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to