Example #1
0
        public IEnumerable <FindResult> EnumFind(string[] CmpWith, string[] Skip = null, bool Back = false,
                                                 IdCharCheck IdCharCheck         = new IdCharCheck(), IList <IResultSkippingHandler> Handlers = null)
        {
            if (!CanContain(CmpWith, Back))
            {
                yield break;
            }

            var RSM = new ResultSkippingManager(Handlers, this, Back);

            while (RSM.Loop())
            {
                var Res = SubstringEquals(RSM.Current, CmpWith, Skip, Back, IdCharCheck);
                if (Res.Position != -1)
                {
                    yield return(Res);

                    if (Back)
                    {
                        RSM.Current -= Res.String.Length - 1;
                    }
                    else
                    {
                        RSM.Current += Res.String.Length - 1;
                    }
                }
            }
        }
Example #2
0
        public int SubstringEquals(int Index, string CmpWith, string[] Skip = null, bool Back = false,
                                   IdCharCheck IdCharCheck = new IdCharCheck())
        {
            var RIndex = Index;

            if (Back)
            {
                RIndex -= CmpWith.Length - 1;
            }

            if (SubstringEqualsS(RIndex, CmpWith, IdCharCheck))
            {
                if (Skip != null)
                {
                    for (var i = 0; i < Skip.Length; i++)
                    {
                        var SkipStr = Skip[i];
                        if (SkipStr.Length >= CmpWith.Length)
                        {
                            for (var SkipPos = -SkipStr.Length + 1; SkipPos < CmpWith.Length; SkipPos++)
                            {
                                if (SubstringEqualsS(RIndex + SkipPos, SkipStr))
                                {
                                    return(-1);
                                }
                            }
                        }
                    }
                }

                return(RIndex);
            }

            return(-1);
        }
Example #3
0
        public IEnumerable <int> EnumFind(string CmpWith, string[] Skip = null, bool Back = false,
                                          IdCharCheck IdCharCheck       = new IdCharCheck(), IList <IResultSkippingHandler> Handlers = null)
        {
            var RSM = new ResultSkippingManager(Handlers, this, Back);

            while (RSM.Loop())
            {
                var Res = SubstringEquals(RSM.Current, CmpWith, Skip, Back, IdCharCheck);
                if (Res != -1)
                {
                    yield return(Res);
                }
            }
        }
Example #4
0
        public FindResult SubstringEquals(int Index, string[] CmpWith, string[] Skip = null, bool Back = false,
                                          IdCharCheck IdCharCheck = new IdCharCheck())
        {
            for (var i = 0; i < CmpWith.Length; i++)
            {
                var e   = CmpWith[i];
                var Res = SubstringEquals(Index, e, Skip, Back, IdCharCheck);
                if (Res != -1)
                {
                    return(new FindResult(i, Res, e));
                }
            }

            return(new FindResult(-1, -1, null));
        }
Example #5
0
        public FindResult Find(string[] CmpWith, string[] Skip = null, bool Back = false,
                               IdCharCheck IdCharCheck         = new IdCharCheck(), IList <IResultSkippingHandler> Handlers = null)
        {
            if (!CanContain(CmpWith, Back))
            {
                return(new FindResult(-1, -1, null));
            }

            var RSM = new ResultSkippingManager(Handlers, this, Back);

            while (RSM.Loop())
            {
                var Res = SubstringEquals(RSM.Current, CmpWith, Skip, Back, IdCharCheck);
                if (Res.Position != -1)
                {
                    return(Res);
                }
            }

            return(new FindResult(-1, -1, null));
        }
Example #6
0
 public int Find(string CmpWith, string[] Skip = null, bool Back = false,
                 IdCharCheck IdCharCheck       = new IdCharCheck(), IList <IResultSkippingHandler> Handlers = null)
 {
     return(String.Find(CmpWith, Skip, Back, IdCharCheck, Handlers));
 }
Example #7
0
 public IEnumerable <FindResult> EnumFind(string[] CmpWith, string[] Skip = null, bool Back = false,
                                          IdCharCheck IdCharCheck         = new IdCharCheck(), IList <IResultSkippingHandler> Handlers = null)
 {
     return(String.EnumFind(CmpWith, Skip, Back, IdCharCheck, Handlers));
 }
Example #8
0
 public FindResult EndsWith(string[] CmpWith, string[] Skip = null, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(String.EndsWith(CmpWith, Skip, IdCharCheck));
 }
Example #9
0
 public FindResult SubstringEquals(int Index, string[] CmpWith, string[] Skip = null,
                                   bool Back = false, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(String.SubstringEquals(Index, CmpWith, Skip, Back, IdCharCheck));
 }
Example #10
0
 public bool EndsWith(string CmpWith, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(String.EndsWith(CmpWith, IdCharCheck));
 }
Example #11
0
 public bool SubstringEqualsS(int Index, string CmpWith, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(String.SubstringEqualsS(Index, CmpWith, IdCharCheck));
 }
Example #12
0
 public FindResult EndsWith(string[] CmpWith, string[] Skip = null, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(SubstringEquals(Length - 1, CmpWith, Skip, true, IdCharCheck));
 }
Example #13
0
 public FindResult StartsWith(string[] CmpWith, string[] Skip = null, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(SubstringEquals(0, CmpWith, Skip, false, IdCharCheck));
 }
Example #14
0
 public bool EndsWith(string CmpWith, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(SubstringEqualsS(Length - CmpWith.Length, CmpWith, IdCharCheck));
 }
Example #15
0
 public bool StartsWith(string CmpWith, IdCharCheck IdCharCheck = new IdCharCheck())
 {
     return(SubstringEqualsS(0, CmpWith, IdCharCheck));
 }
Example #16
0
        public bool SubstringEqualsS(int Index, string CmpWith, IdCharCheck IdCharCheck = new IdCharCheck())
        {
            var CmpLen = CmpWith.Length;

            if (CmpLen == 1)
            {
                if (Index < 0 || Index >= Length)
                {
                    return(false);
                }
                if (String[this.Index + Index] != CmpWith[0])
                {
                    return(false);
                }
            }
            else if (CmpLen != 0)
            {
                if (Index < 0 || CmpLen + Index > Length)
                {
                    return(false);
                }

                var RIndex = Index + this.Index;
                for (var i = 0; i < CmpLen; i++)
                {
                    if (String[RIndex + i] != CmpWith[i])
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(true);
            }

            if (IdCharCheck.CheckIdChars)
            {
                var Func = IdCharCheck.IsIdChar;
                if (Index > 0)
                {
                    var SelfChar = String[this.Index + Index - 1];
                    var CmpChar  = CmpWith[0];

                    if ((Func != null ? Func(SelfChar) : Helper.IsIdChar(SelfChar)) &&
                        (Func != null ? Func(CmpChar) : Helper.IsIdChar(CmpChar)))
                    {
                        return(false);
                    }
                }

                if (Index + CmpLen < Length)
                {
                    var SelfChar = String[this.Index + Index + CmpLen];
                    var CmpChar  = CmpWith[CmpLen - 1];

                    if ((Func != null ? Func(SelfChar) : Helper.IsIdChar(SelfChar)) &&
                        (Func != null ? Func(CmpChar) : Helper.IsIdChar(CmpChar)))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }