SqlUtil.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SQLFormatter
{
    class SqlUtil
    {
        /**
         * 文字列を置き換える. 同一文字列内に複数の変換対象があってもよい。
         * 
         * @param argTargetString
         *            処理対象となる文字列。
         * @param argFrom
         *            変換前の文字列。(ex." <")
         * @param argTo
         *            変換後の文字列。(ex."&lt;")
         * @return 置換された後の文字列。
         */
        public static String replace(String argTargetString, String argFrom, String argTo) {
            String newStr = "";
            int lastpos = 0;

            for (;;) {
                int pos = argTargetString.IndexOf(argFrom, lastpos);
                if (pos == -1) {
                    break;
                }

                newStr += argTargetString.Substring(lastpos, pos);
                newStr += argTo;
                lastpos = pos + argFrom.Length;
            }

            return newStr + argTargetString.Substring(lastpos);
        }
    }
}