Beispiel #1
0
        public static object Get(string GetFrom, GetWhat getwhat)
        {
            string Spattern = @"\s*<.+?>";
            string Epattern = @"<\s*/.+>\s*";

            if (getwhat == GetWhat.StartingTag)
            {
                var Startmatch = Regex.Match(GetFrom, Spattern);
                return(Startmatch.Success && Startmatch.Index == 0 ? Startmatch.Value : null);
            }
            else if (getwhat == GetWhat.EndingTag)
            {
                var   Endmatch_ = Regex.Matches(GetFrom, Epattern);
                Match Endmatch  = null;
                if (Endmatch_.Count > 0)
                {
                    Endmatch = Endmatch_[Endmatch_.Count - 1];
                    return(Endmatch.Index + Endmatch.Length >= GetFrom.Length ? Endmatch.Value : null);
                }
                else
                {
                    return(null);
                }
            }
            else if (getwhat == GetWhat.SurroundingTag)
            {
                return(GetSuroundedtag(GetFrom));
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public static object Get(string GetFrom, GetWhat getwhat)
        {

            string Spattern = @"\s*<.+?>";
            string Epattern = @"<\s*/.+>\s*";

            if (getwhat == GetWhat.StartingTag)
            {
                var Startmatch = Regex.Match(GetFrom, Spattern);
                return Startmatch.Success && Startmatch.Index == 0 ? Startmatch.Value : null;
            }
            else if (getwhat == GetWhat.EndingTag)
            {
                var Endmatch_ = Regex.Matches(GetFrom, Epattern);
                Match Endmatch = null;
                if (Endmatch_.Count > 0)
                {
                    Endmatch = Endmatch_[Endmatch_.Count - 1];
                    return Endmatch.Index + Endmatch.Length >= GetFrom.Length ? Endmatch.Value : null;
                }
                else return null;
                
            }
            else if (getwhat == GetWhat.SurroundingTag) return GetSuroundedtag(GetFrom);
            else return null;
            
        }