当前位置: 首页>>代码示例>>C#>>正文


C# ktString.RemoveFirst方法代码示例

本文整理汇总了C#中KacTalk.ktString.RemoveFirst方法的典型用法代码示例。如果您正苦于以下问题:C# ktString.RemoveFirst方法的具体用法?C# ktString.RemoveFirst怎么用?C# ktString.RemoveFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KacTalk.ktString的用法示例。


在下文中一共展示了ktString.RemoveFirst方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetPattern

        // Set the pattern to use
        public bool SetPattern(ktString Pattern)
        {
            RegexOptions Opt = new RegexOptions();

            switch (m_Mode)
            {
                case ktRE_Mode.PERL:
                    {
                        ktString OPattern = new ktString(Pattern);
                        char Delim = Pattern.First();
                        Pattern.RemoveFirst();

                        int Pos = Find(Pattern, @"[^\\]" + Delim.ToString());
                        if (Pos < 0)
                        {
                            throw new ktError("ktRegEx::SetPattern() : The pattern isn't Perl compatible (" + OPattern + ")", ktERR.NOTFOUND);
                        }
                        else
                        {
                            Pos++;
                        }

                        ktString Modifiers = Pattern.SubStr(Pos + 1);
                        Pattern.Remove((uint)Pos);

                        for (uint I = 0; I < Modifiers.Len(); I++)
                        {
                            //						Console.Write( Modifiers[I].ToString() + ";" );
                            switch (Modifiers[I])
                            {
                                case 'i':
                                    {
                                        Opt = Opt | RegexOptions.IgnoreCase;
                                        break;
                                    }
                                case 'm':
                                    {
                                        Opt = Opt | RegexOptions.Multiline;
                                        break;
                                    }
                                case 'x':
                                    {
                                        Opt = Opt | RegexOptions.IgnorePatternWhitespace;
                                        break;
                                    }
                                case 'A':
                                    {
                                        if (Pattern.First() != '^')
                                        {
                                            Pattern.Prepend("^");
                                        }
                                        break;
                                    }/*
                            case 'i': {
                                Opt = Opt | RegexOptions.IgnoreCase;
                                break;
                             }*/
                            }
                        }

                        break;
                    }
                case ktRE_Mode.Plain:
                    {
                        break;
                    }
                default:
                    {
                        throw new ktError("ktRegExp::SetPattern(): The mode '" + GetModeAsString() +
                                "' is not implementet yet!",
                            ktERR.NOTIMP);
                    }
            }

            // Set the pattern
            m_Pattern = Pattern;

            // Take care of the (if any) exception
            try
            {
                // Create the (internal) regex object
                m_P = new Regex(m_Pattern.GetValue(), Opt);
            }
            catch (ktError Ex)
            {
                SetError("Couldn't set pattern and create a new (internal) Regex object" +
                         Ex.Message, ktERR.REGEX_COULDNT_SET_PATTERN);
                return false;
            }
            catch (Exception Ex)
            {
                SetError("Couldn't set pattern and create a new (internal) Regex object" +
                         Ex.Message, ktERR.REGEX_COULDNT_SET_PATTERN);
                return false;
            }

            return true;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:99,代码来源:ktRegExp.cs

示例2: MapArguments

        protected bool MapArguments(ktList Arguments)
        {
            if (((Arguments == null) || Arguments.IsEmpty()) &&
                 ((m_Arguments == null) || m_Arguments.IsEmpty()))
            {
                return true;
            }
            else if ((m_Arguments == null) || m_Arguments.IsEmpty())
            {
                return true;
            }

            ktString Name = new ktString();
            ktString RestName = null;
            ktList Rest = null, CurrArgL = null;
            ktValue Arg = null, CurrArg = null, Arg2Add = null;
            //bool GoOn = true;

            CurrArgL = Arguments.First;

            m_Arguments.Reset();
            foreach (ktList AL in m_Arguments)
            {

                Arg2Add = null;

                /*if ((CurrArgL == null) || (CurrArgL.Node == null) || (CurrArgL.Node.Value == null)) {
                    Arg2Add = ktValue.Null;
                }*/
                if ((AL == null) || (AL.Node == null) || (AL.Node.Value == null))
                {
                    ktDebug.Log("NA");
                    // ????????????????????????????????????????????????????????????
                    Arg2Add = ktValue.Null;
                }
                else
                {
                    Arg = (ktValue)AL.Node.Value;
                    Name = Arg.Name;

                    if ((CurrArgL == null) || (CurrArgL.Node == null) || (CurrArgL.Node.Value == null))
                    {
                        ktDebug.Log("NULL");
                        if (Arg.Value != null)
                        {
                            Arg2Add = new ktValue(Name, Arg.Type, Arg.Value, Arg.HardType, Arg.Constant);
                        }
                        else
                        {
                            Arg2Add = new ktValue(Name, "null", null, true, true);
                        }
                        AddVariable(Arg2Add);
                        continue;
                    }
                    CurrArg = (ktValue)CurrArgL.Node.Value;

                    if (Name[0] == '#')
                    {
                        Name.RemoveFirst();
                        Arg2Add = new ktValue(Name, "ktList", Arguments, true, false);
                    }
                    else if (Name[0] == '$')
                    {
                        Name.RemoveFirst();
                        RestName = Name;
                        Rest = new ktList();

                        while (CurrArgL != null)
                        {
                            Arg2Add = new ktValue(CurrArg);

                            if (CurrArgL != null)
                            {
                                CurrArgL = CurrArgL.Next;

                                if ((CurrArgL == null) || (CurrArgL.Node == null) ||
                                    (CurrArgL.Node.Value == null))
                                {
                                    continue;
                                }
                                else
                                {
                                    CurrArg = (ktValue)CurrArgL.Node.Value;
                                }
                            }
                        }
                    }
                    else
                    {
                        if ((Arg.HardType) && (!Arg.CheckType(CurrArg)))
                        {
                            throw new ktError("ktFunction::MapArguments() : Didn't get a value with the right type for the argument '" +
                                    Name + "' in the function " +
                                    m_Name + "!", ktERR.WRONGTYPE);
                        }

                        Arg2Add = new ktValue(CurrArg);
                    }
                }

//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:ktFunction.cs

示例3: Matches

        // Match and compare...
        // Find, but with a mask (using ? and *)
        public bool Matches(ktString Mask)
        {
            /* ** <note>
               For now we just cross our fingers and hopes that this function (/method?)
               actually works. We haven't runned this code yet.
                (BTW this goes with most of the whole class...)</note>
            ***/
            bool Match = false;
            bool GoOn = true;

            int Pos;
            ktTripple Joker = 0; // 1 == * and 2 == ?

            ktString MatchTmp;
            ktString Str = new ktString(GetValue());

            // Don't stop until we say so
            while (GoOn)
            {
                Joker = 0;

                // If there's no more "Joker"
                if ((Pos = ktRegEx.Find(Mask.GetValue(), "\\*|\\?")) < 0)
                {
                    // If (the rest of) the mask matches the string
                    if (Mask == Str)
                    {
                        // Stop looping
                        GoOn = false;
                        // And "OK it"
                        Match = true;
                    }
                    else
                    {
                        // Stop looping
                        GoOn = false;
                        // Didn' match...
                        Match = false;
                    }
                }
                else
                {
                    // Find a "Joker" and get everything infront of it
                    MatchTmp = Mask.SubStr(0, Pos);
                    // Remove what we got from the mask
                    Mask.Remove(0, MatchTmp.Length());

                    // Chech the "Joker"
                    //  If the first char is * in the "new mask"
                    //   then indicate that
                    if (Mask.First() == '*')
                        Joker = 1;
                    //  Or if it's ?...
                    else
                        Joker = 2;

                    // Remove the "Joker"
                    Mask.RemoveFirst();

                    // If this part of the mask doesn't match... (simply not a match)
                    if ((!MatchTmp.IsEmpty()) && (MatchTmp != Str.SubStr(0, MatchTmp.Length())))
                    {
                        // Stop looping
                        GoOn = false;
                        Match = false;
                    }
                    else
                    {
                        // As we now that this part of the mask matches the string
                        //  Remove that part from the string
                        Str.Remove(0, MatchTmp.Length());

                        // If the "Joker" is *
                        if (Joker == 1)
                        {
                            // Get the position of the next "Joker"
                            Pos = ktRegEx.Find(Mask.GetValue(), "\\*|\\?");

                            // If we didn't find a new "Joker"
                            if (Pos < 0)
                            {
                                // get the length of the rest of the mask ("find the end")
                                Pos = Mask.Length();
                                // If Pos is 0
                                if (Pos == 0)
                                    // No more mask...
                                    Pos = -1;
                            }

                            // If Pos is less than 0
                            //  This (should) means that the * was the last thing in
                            //   the mask and should therefor match the rest of the string
                            if (Pos < 0)
                            {
                                // Stop looping
                                GoOn = false;
                                // It's a match...
                                Match = true;
//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:ktString.cs


注:本文中的KacTalk.ktString.RemoveFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。