Ejemplo n.º 1
0
        /// <summary>
        /// Obtiene el segundo texto colindante, a la izquierda del
        /// primer texto colindante.
        /// </summary>
        /// <returns>Segundo texto colindante por la izquierda.</returns>
        private Match GetLowerSecond()
        {
            if (_MatchLowerFirst == null)
            {
                return(null);
            }

            Match match = Regex.Match(_ParserMatch.TextContext,
                                      TxtRegex.EscapeReserved(_MatchLowerFirst.Value) +
                                      TxtRegex.EscapeReserved(_MatchToken.Value));

            if (!match.Success)
            {
                return(null);
            }

            return(GetLower(match, _ParserMatch.TextContext));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Obtiene el texto colindante más próximo por la derecha.
        /// </summary>
        /// <returns>Texto colindante más próximo por la derecha.</returns>
        private Match GetUpper()
        {
            string token = _ParserMatch.TextValue;

            string patternUpper = string.Format(@"(?<={0})[\s\n]+[^\s\n]+",
                                                TxtRegex.EscapeReserved(token));

            MatchCollection upperMatches = Regex.Matches(_ParserMatch.TextContext, patternUpper);

            foreach (Match matchUpper in upperMatches)
            {
                int tokenEnd = _ParserMatch.MatchIndex + _ParserMatch.TextValue.Length;
                if (matchUpper.Index == tokenEnd)
                {
                    return(matchUpper);
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Obtiene un texto colindante por la izquierda de un
        /// texto objetivo.
        /// </summary>
        /// <param name="match">Match con el texto objetivo utilizada
        /// para obtener el texto objetivo y la posición inicial
        /// del mismo (pardescartar coincidencia múltiples).</param>
        /// <param name="container">texto contenedor del texto objetivo.</param>
        /// <returns>Match con el texto colindante encontrado.</returns>
        private Match GetLower(Match match, string container)
        {
            string token = match.Value;

            string patternLower = string.Format(@"[^\s\n]+[\s\n]+(?={0})",
                                                TxtRegex.EscapeReserved(token));

            MatchCollection lowerMatches = Regex.Matches(_ParserMatch.TextContext, patternLower);

            foreach (Match matchLower in lowerMatches)
            {
                string lower      = matchLower.Value;
                int    tokenStart = matchLower.Index + lower.Length;
                if (match.Index == tokenStart)
                {
                    return(matchLower);
                }
            }

            return(null);
        }