May be I'll post here some useful scripts...
Let's start with Position function, use like pos=P(text,subs) and it will place position of first occurrence of subs at text or -1 if not found.
Use example:
Math::Script "r0=P('Where it is?', 'it')" will place 6 to $0.Source (should be defined before use of course):
Math::Script /NOUNLOAD "P(s,e, p,i) (p=-1;i=0; #{(i<l(s))&&(p<0), #[s[i,i+l(e)-1]==e, p=i]; i++}; p)" The second one is Search And Replace, result=SaR(text,s,r). s and r are the arrays of search and replace text pairs.Example:
Math::Script "a = 'Hello\r\nWorld!!!'; a = SaR(a,{'\r','\n'},{'$\r','$\n'}); r0 = a" this will place hello world with real $\r and $\n to $0.Source:
Math::Script /NOUNLOAD 'SaR(s,fa,ra, i,f,r,e,p) (i=0;#{i<l(fa),e=l(f=fa[i]);r=ra[i];p=0;#{p<l(s),#[s[p,p+e-1]==f,s=(s[,p-1])+r+(s[p+e,]);p+=l(r), p++]}; i++}; s);' 