Пример #1
0
        private void buildRegEX()
        {
            RegEXPattern = "^";
            RegEXPatternWithoutPrefix      = "^";
            RegEXPatternWithoutSufix       = "^";
            RegEXPatternWithoutPrefixSufix = "^";
            string pref;

            pref = Prefix.Replace(",", ", *").Replace("[", @"\[").Replace("]", @"\]");
            string postf;

            postf = Postfix.Replace(",", ", *").Replace("[", @"\[").Replace("]", @"\]");
            pref  = pref.Replace(".", @"\.").Replace("+", @"\+");
            postf = postf.Replace(".", @"\.").Replace("+", @"\+");
            pref  = pref.Replace("(", @"\(").Replace(")", @"\)" + numPostMod);
            postf = postf.Replace("(", @"\(").Replace(")", @"\)" + numPostMod);

            RegEXPattern             += pref;
            RegEXPatternWithoutSufix += pref;

            if (Bytes == 0)
            {
                RegEXPattern += postf + "$";
                return;
            }

            if (Type == "string with spaces")
            {
                RegEXPattern += @"[^\" + '"' + "]+" + postf + "$";
                RegEXPatternWithoutPrefix      += @"[^\" + '"' + "]+" + postf + "$";
                RegEXPatternWithoutSufix       += @"[^\" + '"' + "]+" + "$";
                RegEXPatternWithoutPrefixSufix += @"[^\" + '"' + "]+" + "$";
                return;
            }
            if (Type == "string")
            {
                string adder = "";
                if (Prefix.Length > 0)
                {
                    adder = @"\d";
                }
                RegEXPattern += @"([" + adder + @"a-zA-Z]|_)+(\.*_*[\da-zA-Z]*)*" + numPostMod + postf + "$";
                RegEXPatternWithoutPrefix      += @"([" + adder + @"a-zA-Z]|_)+(\.*_*[\da-zA-Z]*)*" + numPostMod + postf + "$";
                RegEXPatternWithoutSufix       += @"([" + adder + @"a-zA-Z]|_)+(\.*_*[\da-zA-Z]*)*" + numPostMod + "$";
                RegEXPatternWithoutPrefixSufix += @"([" + adder + @"a-zA-Z]|_)+(\.*_*[\da-zA-Z]*)*" + numPostMod + "$";
                return;
            }
            if (Type == "fixed" && Bytes < 0)
            {
                RegEXPattern += pref + "*" + numPostMod + postf + "$";
                RegEXPatternWithoutPrefix      += pref + "*" + numPostMod + postf + "$";
                RegEXPatternWithoutSufix       += pref + "*" + numPostMod + "$";
                RegEXPatternWithoutPrefixSufix += pref + "*" + numPostMod + "$";
                return;
            }

            int    bn   = Bytes * 8;
            string bnum = "%[0,1]{1," + bn + "}";
            int    hn   = Bytes * 2;
            string hnum = @"\$[\dA-Fa-f]{1," + hn + "}";
            string dnum = "0*" + dnums[Bytes - 1];

            //RegEXPattern += "[" + bnum + "-" + hnum + "-" + dnum + "]" + postf;
            RegEXPattern += "(" + bnum + "|" + hnum + "|" + dnum + ")" + numPostMod + postf + "$";
            RegEXPatternWithoutPrefix      += "(" + bnum + "|" + hnum + "|" + dnum + ")" + numPostMod + postf + "$";
            RegEXPatternWithoutSufix       += "(" + bnum + "|" + hnum + "|" + dnum + ")" + numPostMod + "$";
            RegEXPatternWithoutPrefixSufix += "(" + bnum + "|" + hnum + "|" + dnum + ")" + numPostMod + "$";
        }
Пример #2
0
 public LovereadSettings(int start, int end, int bookId)
 {
     StartPoint = start;
     EndPoint   = end;
     Postfix    = Postfix.Replace("{BookId}", bookId.ToString());
 }