예제 #1
0
        public Object _split(INakoFuncCallInfo info)
        {
            string s = info.StackPopAsString();
            string a = info.StackPopAsString();

            return(__extract(info, s, a, false));
        }
예제 #2
0
        public Object _extract(INakoFuncCallInfo info)
        {
            string       s   = info.StackPopAsString();
            string       a   = info.StackPopAsString();
            HtmlDocument doc = new HtmlDocument();

            doc.OptionFixNestedTags = true;
            doc.OptionOutputAsXml   = true;
            doc.LoadHtml(s);
            string             html  = doc.DocumentNode.OuterHtml;
            HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes(String.Format(@"//{0}", a));
            NakoVarArray       res   = info.CreateArray();

            if (nodes != null)
            {
                for (int i = 0; i < nodes.Count; i++)
                {
                    HtmlNode node = nodes[i];
                    if (html.Contains(node.OuterHtml))
                    {
                        res.SetValue(i, node.InnerHtml);
                        html = html.Remove(html.IndexOf(node.OuterHtml), node.OuterHtml.Length);
                    }
                }
            }
            return(res);
        }
예제 #3
0
        public object _relativeUrl(INakoFuncCallInfo info)
        {
            string a = info.StackPopAsString();
            string b = info.StackPopAsString();

            return(new Uri(new Uri(b), a).AbsoluteUri);
        }
예제 #4
0
        public Object _matchAll(INakoFuncCallInfo info)
        {
            string s       = info.StackPopAsString();
            string pattern = info.StackPopAsString();

            m = Regex.Match(s, pattern);
            NakoVarArray res    = info.CreateArray();
            int          index  = 0;
            NakoVarArray groups = new NakoVarArray();

//          NakoVariable ret = new NakoVariable();
            while (m.Success)
            {
                res.SetValue(index, m.Value);
                NakoVarArray subgroups = new NakoVarArray();
                for (int i = 0; i < m.Groups.Count; i++)
                {
                    subgroups.SetValue(i, m.Groups[i].Value);
                }
                groups.Add(subgroups);
//              for(int i = 0;i < m.Groups.Count;i++){
//                  groups.SetValue(i,m.Groups[i].Value);
//              }
//              ret.Type = NakoVarType.Array;
//              ret.Body = groups;
                index++;
                m = m.NextMatch();
            }
            info.SetVariableValue("抽出文字列", groups);
            return(res);
        }
예제 #5
0
        private object _occurrence(INakoFuncCallInfo info)
        {
            string s      = info.StackPopAsString();
            string search = info.StackPopAsString();

            return((int)((s.Length - s.Replace(search, "").Length) / search.Length));
        }
예제 #6
0
        /// <summary>
        /// 文字列検索
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private object _search(INakoFuncCallInfo info)
        {
            string s      = info.StackPopAsString();
            string needle = info.StackPopAsString();

            return(s.IndexOf(needle) + 1);
        }
예제 #7
0
        private object _cutRange(INakoFuncCallInfo info)
        {
            object sr = info.StackPop();
            string a  = info.StackPopAsString();
            string b  = info.StackPopAsString();

            string[] predelim  = { a };
            string[] postdelim = { b };
            if (!(sr is NakoVariable))
            {
                throw new ApplicationException("『範囲切り取る』に変数が設定されていません");
            }
            object s = ((NakoVariable)sr).Body;
            string ret;

            if (s is string)
            {
                string[] split_s = ((string)s).Split(predelim, 2, StringSplitOptions.None);
                if (split_s.Length == 2)
                {
                    ret = split_s[1];
                    string[] post_split_s = ret.Split(postdelim, 2, StringSplitOptions.None);
                    if (post_split_s.Length == 2)
                    {
                        ((NakoVariable)sr).SetBodyAutoType(split_s[0] + post_split_s[1]);
                        return(post_split_s[0]);
                    }
                }
            }
            return(null);
        }
예제 #8
0
        public Object _urlDecode(INakoFuncCallInfo info)
        {
            string s = info.StackPopAsString();
            string e = info.StackPopAsString();

            return(HttpUtility.UrlDecode(s, Encoding.GetEncoding(e)));
        }
예제 #9
0
        // Define Method
        public Object _openFile(INakoFuncCallInfo info)
        {
            string fileName = info.StackPopAsString();
            string e        = info.StackPopAsString();

            // Exists?
            if (!System.IO.File.Exists(fileName))
            {
                throw new NakoPluginRuntimeException("ファイル『" + fileName + "』は存在しません。");
            }
            // Load
            //string src = File.ReadAllText(fileName);
            string src;

            if (e == "Auto")
            {
                src = StrUnit.LoadFromFileAutoEnc(fileName);
            }
            else
            {
                if (sjis.Contains(e))
                {
                    src = File.ReadAllText(fileName, Encoding.GetEncoding(932));
                }
                else
                {
                    src = File.ReadAllText(fileName, Encoding.GetEncoding(e));
                }
            }
            return(src);
        }
예제 #10
0
        private object _strpos(INakoFuncCallInfo info)
        {
            string s  = info.StackPopAsString();
            string ss = info.StackPopAsString();
            int    i  = s.IndexOf(ss);

            return(i + 1);  // 1からはじまるので
        }
예제 #11
0
//        public Object _group(INakoFuncCallInfo info){
//          NakoVarArray groups = new NakoVarArray();
//          if(m is Match && m.Success){
//              for(int i = 0;i < m.Groups.Count;i++){
//                  groups.SetValue(i,m.Groups[i].Value);
//              }
//              return groups;
//          }
//          return null;
//        }

        public Object _replace(INakoFuncCallInfo info)
        {
            string s       = info.StackPopAsString();
            string pattern = info.StackPopAsString();
            string replace = info.StackPopAsString();

            return(Regex.Replace(s, pattern, replace));
        }
예제 #12
0
        public Object _moveFile(INakoFuncCallInfo info)
        {
            string f1 = info.StackPopAsString();
            string f2 = info.StackPopAsString();

            File.Move(f1, f2);
            return(null);
        }
예제 #13
0
        public object _format(INakoFuncCallInfo info)
        {
            string   a      = info.StackPopAsString();
            string   format = info.StackPopAsString();
            DateTime aDate  = DateTime.Parse(a);

            return(aDate.ToString(format));
        }
예제 #14
0
        private object _insert(INakoFuncCallInfo info)
        {
            StringBuilder s   = new StringBuilder(info.StackPopAsString());
            int           cnt = NadesikoPositionToCSPosition((int)info.StackPopAsInt());
            string        a   = info.StackPopAsString();

            return(s.Insert(cnt, a).ToString());
        }
예제 #15
0
        /// <summary>
        /// 置換
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private object _replace(INakoFuncCallInfo info)
        {
            string s       = info.StackPopAsString();
            string search  = info.StackPopAsString();
            string replace = info.StackPopAsString();

            return(s.Replace(search, replace));
        }
예제 #16
0
        public object _append(INakoFuncCallInfo info)
        {
            string s        = info.StackPopAsString();
            string fileName = info.StackPopAsString();

            System.Text.Encoding enc = new System.Text.UTF8Encoding(false);
            System.IO.File.AppendAllText(fileName, s, enc);
            return(null);
        }
예제 #17
0
        public object _daysDifference(INakoFuncCallInfo info)
        {
            string   a     = info.StackPopAsString();
            string   b     = info.StackPopAsString();
            DateTime aDate = DateTime.Parse(a);
            DateTime bDate = DateTime.Parse(b);

            return(bDate.Subtract(aDate).TotalDays);
        }
예제 #18
0
        public Object _diffhours(INakoFuncCallInfo info)
        {
            string   atime     = info.StackPopAsString();
            string   btime     = info.StackPopAsString();
            DateTime adatetime = DateTime.Parse(atime);
            DateTime bdatetime = DateTime.Parse(btime);

            return(adatetime.Subtract(bdatetime).TotalHours);
        }
예제 #19
0
        public object _format(INakoFuncCallInfo info)
        {
            CultureInfo culture = new CultureInfo("ja-JP", true);
            string      a       = info.StackPopAsString();
            string      format  = info.StackPopAsString();
            DateTime    aDate   = DateTime.Parse(a);

            return(aDate.ToString(format, culture));
        }
예제 #20
0
        public Object _sendKeys(INakoFuncCallInfo info)
        {
            string title = info.StackPopAsString();
            string keys  = info.StackPopAsString();

            EnumWindows.ActivateWindow(title);
            SendKeys.Send(keys);
            return(null);
        }
예제 #21
0
        public object _downloadGet(INakoFuncCallInfo info)
        {
            string    url    = info.StackPopAsString();
            string    file   = info.StackPopAsString();
            WebClient client = new WebClient();

            client.DownloadFile(url, file);
            client.Dispose();
            return(null);
        }
예제 #22
0
        /// <summary>
        /// 単置換
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private object _replace_a(INakoFuncCallInfo info)
        {
            string s       = info.StackPopAsString();
            string search  = info.StackPopAsString();
            string replace = info.StackPopAsString();
            int    index   = s.IndexOf(search);
            string pre     = s.Substring(0, index);
            string post    = s.Substring(index + search.Length);

            return(pre + replace + post);
        }
예제 #23
0
        public Object _split(INakoFuncCallInfo info)
        {
            string s       = info.StackPopAsString();
            string pattern = info.StackPopAsString();

            string[]     splitted = Regex.Split(s, pattern);
            NakoVarArray arr      = info.CreateArray();

            for (int i = 0; i < splitted.Length; i++)
            {
                arr.SetValue(i, splitted[i]);
            }
            return(arr);
        }
예제 #24
0
        private object _explode(INakoFuncCallInfo info)
        {
            string s = info.StackPopAsString();
            string a = info.StackPopAsString();

            string[]     splitted = s.Split(new string[] { a }, StringSplitOptions.None);
            NakoVarArray arr      = info.CreateArray();

            for (int i = 0; i < splitted.Length; i++)
            {
                arr.SetValue(i, splitted[i]);
            }
            return(arr);
        }
예제 #25
0
        public object _add(INakoFuncCallInfo info)
        {
            string s        = info.StackPopAsString();
            string addDate  = info.StackPopAsString();
            string addOrDel = addDate.Substring(0, 1);

            string[] span = addDate.Substring(1).Replace('-', '/').Split('/');
            if (span.Length != 3)
            {
                throw new ArgumentException();
            }
            DateTime current = DateTime.Parse(s);            //TODO:ParseExactを使うか?

            return(current.AddYears(int.Parse(addOrDel + span[0])).AddMonths(int.Parse(addOrDel + span[1])).AddDays(int.Parse(addOrDel + span[2])).ToString());
        }
예제 #26
0
        private object _convert_kana_to_roman(INakoFuncCallInfo info)
        {
            string s = info.StackPopAsString();

            //TODO: 手動実装(めんどー)キャキュキョから始まって最後に1文字カナを変換
            return(s);
        }
예제 #27
0
        /// <summary>
        /// 左からN文字の部分文字列
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private object _left(INakoFuncCallInfo info)
        {
            string s   = info.StackPopAsString();
            int    len = (int)info.StackPopAsInt();

            return(s.Substring(0, len));
        }
예제 #28
0
        /// <summary>
        /// 切り取る
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private object _cut(INakoFuncCallInfo info)
        {
            object sr = info.StackPop();
            string a  = info.StackPopAsString();

            string[] delim = { a };
            if (!(sr is NakoVariable))
            {
                throw new ApplicationException("『切り取る』に変数が設定されていません");
            }
            object s = ((NakoVariable)sr).Body;
            object ret;

            if (s is string)
            {
                string[] split_s = ((string)s).Split(delim, 2, StringSplitOptions.None);
                if (split_s.Length == 2)
                {
                    ret = split_s[1];
                    ((NakoVariable)sr).SetBodyAutoType(ret);
                    return(split_s[0]);
                }
            }
            return(null);
        }
예제 #29
0
        /// <summary>
        /// 右から部分文字列を返す
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private object _right(INakoFuncCallInfo info)
        {
            string s   = info.StackPopAsString();
            int    len = (int)info.StackPopAsInt();

            return(s.Substring(s.Length - len));
        }
예제 #30
0
        private object _concat(INakoFuncCallInfo info)
        {
            object ar = info.StackPop();
            string s  = info.StackPopAsString();

            if (!(ar is NakoVarArray))
            {
                throw new NakoPluginRuntimeException("『結合』の引数が配列ではありません");
            }
            StringBuilder sb    = new StringBuilder();
            NakoVarArray  arr   = (NakoVarArray)ar;
            int           index = 0;

            while (arr.GetValue(index) != null)
            {
                if (index > 0)
                {
                    sb.Append(s);
                }
                object var = arr.GetValue(index);
                if (var != null)
                {
                    sb.Append(var.ToString());
                }
                index++;
            }
            return(sb.ToString());
        }
예제 #31
0
 // Define Method
 public object _abort(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     foreach(System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName(s)){
         p.Kill();
     }
     return null;
 }
예제 #32
0
 public object _decode(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     var json = fastJSON.JSON.Instance.Parse(s);
     NakoVarArray a = ArrayToNakoVarArray(json);
     return a;
     //            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     //            object json = serializer.Deserialize<object>(s);
 }
예제 #33
0
 // Define Method
 public Object _eval(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     NakoCompiler compiler = new NakoCompiler();
     compiler.DirectSource = s;
     NakoInterpreter runner = new NakoInterpreter(compiler.Codes);
     runner.Run();
     Console.WriteLine("EVALLOG=" + runner.PrintLog);
     return runner.globalVar.GetValue(0);
 }
예제 #34
0
        public Object _directoryDialog(INakoFuncCallInfo info)
        {
            string s = info.StackPopAsString();

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            //RootFolderには特殊フォルダしか指定できないのでとりあえずSelectedPathで代用
            fbd.SelectedPath = s;
            //ダイアログを表示する
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                //OKボタンがクリックされたとき
                return fbd.SelectedPath;
            }
            return null;
        }
예제 #35
0
 /// <summary>
 /// 文字列検索
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _search(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     string needle = info.StackPopAsString();
     return s.IndexOf(needle) + 1;
 }
예제 #36
0
 /// <summary>
 /// 右から部分文字列を返す
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _right(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     int len = (int)info.StackPopAsInt();
     return s.Substring(s.Length-len);
 }
예제 #37
0
 private object _cutRange(INakoFuncCallInfo info)
 {
     object sr = info.StackPop();
     string a = info.StackPopAsString();
     string b = info.StackPopAsString();
     string[] predelim = {a};
     string[] postdelim = {b};
     if(!(sr is NakoVariable)){
         throw new ApplicationException("『範囲切り取る』に変数が設定されていません");
     }
     object s = ((NakoVariable)sr).Body;
     string ret;
     if(s is string){
         string[] split_s = ((string)s).Split(predelim,2,StringSplitOptions.None);
         if(split_s.Length==2){
            ret = split_s[1];
            string[] post_split_s = ret.Split(postdelim,2,StringSplitOptions.None);
            if(post_split_s.Length==2){
            ((NakoVariable)sr).SetBodyAutoType(split_s[0] + post_split_s[1]);
             return post_split_s[0];
             }
         }
     }
     return null;
 }
예제 #38
0
 private object _alnumToEn(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     return Regex.Replace(s,@"[0-9A-Za-z:- ]+",delegate(Match m){
     if(NWEnviroment.isWindows()){
             return Strings.StrConv(m.Value, VbStrConv.Narrow, 0);
     }else{
         return LinuxCommand.execute("echo '"+m.Value+"' | nkf -Z3").Replace("\n","");
     }
     });
 }
예제 #39
0
 // Define Method
 public object _open(INakoFuncCallInfo info)
 {
     string fileName = info.StackPopAsString();
     string mode = info.StackPopAsString();
     switch (mode) {
     case "作":
      return new FileStream(fileName,FileMode.Create);
     case "読":
      return new StreamReader(fileName);
     case "書":
      return new StreamWriter(fileName);
     default:
      return new StreamReader(fileName);
     }
 }
예제 #40
0
 /// <summary>
 /// 左からN文字の部分文字列
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _left(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     int len = (int)info.StackPopAsInt();
     return s.Substring(0,len);
 }
예제 #41
0
 /// <summary>
 /// トリム
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _trim(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     return s.Trim();
 }
예제 #42
0
 /// <summary>
 /// 文字抜き出す
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _extract(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     int a = NadesikoPositionToCSPosition((int)info.StackPopAsInt());
     int cnt = (int)info.StackPopAsInt();
     return s.Substring(a,cnt);
 }
예제 #43
0
 private object _insert(INakoFuncCallInfo info)
 {
     StringBuilder s = new StringBuilder(info.StackPopAsString());
     int cnt = NadesikoPositionToCSPosition((int)info.StackPopAsInt());
     string a = info.StackPopAsString();
     return s.Insert(cnt,a).ToString();
 }
예제 #44
0
 private object _explode(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     string a = info.StackPopAsString();
     string[] splitted = s.Split(new string[]{a},StringSplitOptions.None);
     NakoVarArray arr = info.CreateArray();
     for(int i=0;i<splitted.Length;i++){
         arr.SetValue(i,splitted[i]);
     }
     return arr;
 }
예제 #45
0
 private object _Em(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     char c1 = s[0];
     int num = Encoding.GetEncoding("Shift_JIS").GetByteCount(c1.ToString());
     if(num==2){
         return 1;
     }else{
         return 0;
     }
 }
예제 #46
0
 private object _degrade(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     char[] splitted = s.ToCharArray();
      NakoVarArray arr = info.CreateArray();
     for(int i=0;i<splitted.Length;i++){
         arr.SetValue(i,splitted[i]);
     }
     return arr;
 }
예제 #47
0
 private object _strpos(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     string ss = info.StackPopAsString();
     int i = s.IndexOf(ss);
     return (i + 1); // 1からはじまるので
 }
예제 #48
0
 // Define Method
 /// <summary>
 /// 文字列の長さを調べる
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _length(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     return s.Length;
 }
예제 #49
0
 private object _toKana(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
      if(NWEnviroment.isWindows()){
         return Strings.StrConv(s, VbStrConv.Hiragana, 0);
      }else{
      return LinuxCommand.execute("echo '"+s+"' | nkf --hiragana").Replace("\n","");
      }
 }
예제 #50
0
 private object _num(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     char c1 = s[0];
     int num;
     if(int.TryParse(c1.ToString(), out num)){
         return 1;
     }else{
         return 0;
     }
 }
예제 #51
0
 private object _uppercase(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     return s.ToUpper();
 }
예제 #52
0
 private object _occurrence(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     string search = info.StackPopAsString();
     return (int)((s.Length - s.Replace(search,"").Length)/search.Length);
 }
예제 #53
0
 /// <summary>
 /// 配列キー存在?
 /// </summary>
 /// <param name="array"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 private object _hasKey(INakoFuncCallInfo info)
 {
     object ar = info.StackPop();
     NakoVarArray arv = (NakoVarArray)ar;
     string searchKey = info.StackPopAsString ();
     if (arv.Type != NakoVarType.Array)
     {
         throw new NakoPluginArgmentException("『存在』の引数が配列ではありません。");
     }
     string[] keys = arv.GetKeys();
     NakoVarArray res = info.CreateArray();
     foreach (string key in keys)
     {
         if (key == searchKey)
             return 1;
     }
     return 0;
 }
예제 #54
0
 private object _convert_kana_to_roman(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     //TODO: 手動実装(めんどー)キャキュキョから始まって最後に1文字カナを変換
     return s;
 }
예제 #55
0
 public object _writeLine(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     object stream = info.StackPop();
     if(stream is StreamWriter){
         StreamWriter filestream = (StreamWriter)stream;
         filestream.WriteLine(s);
     }
     return null;
 }
예제 #56
0
 /// <summary>
 /// 文字列に追加する
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _append(INakoFuncCallInfo info)
 {
     object sr = info.StackPop();
     object s = ((NakoVariable)sr).Body;
     string a = info.StackPopAsString();
     string ret = (string)s + a;
      ((NakoVariable)sr).SetBodyAutoType(ret);
     return null;
 }
예제 #57
0
 /// <summary>
 /// 置換
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _replace(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     string search = info.StackPopAsString();
     string replace = info.StackPopAsString();
     return s.Replace(search,replace);
 }
예제 #58
0
 /// <summary>
 /// 切り取る
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _cut(INakoFuncCallInfo info)
 {
     object sr = info.StackPop();
     string a = info.StackPopAsString();
     string[] delim = {a};
     if(!(sr is NakoVariable)){
         throw new ApplicationException("『切り取る』に変数が設定されていません");
     }
     object s = ((NakoVariable)sr).Body;
     object ret;
     if(s is string){
         string[] split_s = ((string)s).Split(delim,2,StringSplitOptions.None);
         if(split_s.Length==2){
            ret = split_s[1];
            ((NakoVariable)sr).SetBodyAutoType(ret);
             return split_s[0];
         }
     }
     return null;
 }
예제 #59
0
 private object _concat(INakoFuncCallInfo info)
 {
     object ar = info.StackPop();
     string s = info.StackPopAsString();
     if (!(ar is NakoVarArray))
     {
         throw new NakoPluginRuntimeException("『結合』の引数が配列ではありません");
     }
     StringBuilder sb = new StringBuilder();
     NakoVarArray arr = (NakoVarArray)ar;
     int index = 0;
     while(arr.GetValue(index)!=null){
         if(index > 0) sb.Append(s);
         object var = arr.GetValue(index);
         if (var != null)
         {
             sb.Append(var.ToString());
         }
         index++;
     }
     return sb.ToString();
 }
예제 #60
0
 /// <summary>
 /// 単置換
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private object _replace_a(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     string search = info.StackPopAsString();
     string replace = info.StackPopAsString();
     int index = s.IndexOf(search);
     string pre = s.Substring(0,index);
     string post = s.Substring(index+search.Length);
     return pre + replace + post;
 }