<commit_before>﻿#region Using

using System;

#endregion

namespace PortableExtensions
{
    /// <summary>
    ///     Class containing some extension methods for <see cref="string" />.
    /// </summary>
    public static partial class StringEx
    {
        /// <summary>
        ///     Gets the part of the string after the specified value, starting at the given start index.
        /// </summary>
        /// <exception cref="ArgumentNullException">The string can not be null.</exception>
        /// <param name="str">The input string.</param>
        /// <param name="value">The value to search.</param>
        /// <param name="startIndex">The start index of the substring.</param>
        /// <returns>The string after the specified value.</returns>
        public static String GetAfter( this String str, String value, Int32 startIndex = 0 )
        {
            str.ThrowIfNull( () => str );

            return GetAfter( str, value, startIndex, str.Length - startIndex );
        }

        /// <summary>
        ///     Gets the part of the string after the specified value, starting at the given start index
        ///     and ending after the specified number of characters.
        /// </summary>
        /// <exception cref="ArgumentNullException">The string can not be null.</exception>
        /// <param name="str">The input string.</param>
        /// <param name="value">The value to search.</param>
        /// <param name="startIndex">The start index of the string.</param>
        /// <param name="length">The length of the string, from the start index.</param>
        /// <returns>The string after the specified value.</returns>
        public static String GetAfter( this String str, String value, Int32 startIndex, Int32 length )
        {
            str.ThrowIfNull( () => str );
            value.ThrowIfNull( () => value );

            if ( startIndex < 0 || startIndex + length > str.Length )
                throw new ArgumentOutOfRangeException( "The specified range is invalid." );

            str = str.Substring( startIndex, length );
            return !str.Contains( value )
                       ? String.Empty
                       : str.Substring( str.IndexOf( value, StringComparison.Ordinal ) + value.Length );
        }
    }<commit_msg>Add new overload for String.<commit_after>﻿#region Using

using System;

#endregion

namespace PortableExtensions
{
    /// <summary>
    ///     Class containing some extension methods for <see cref="string" />.
    /// </summary>
    public static partial class StringEx
    {
        /// <summary>
        ///     Gets the part of the string after the specified value, starting at the given start index.
        /// </summary>
        /// <exception cref="ArgumentNullException">str can not be null.</exception>
        /// <exception cref="ArgumentNullException">value can not be null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The specified start index is invalid.</exception>
        /// <param name="str">The input string.</param>
        /// <param name="value">The value to search.</param>
        /// <param name="startIndex">The start index of the substring.</param>
        /// <returns>The string after the specified value.</returns>
        public static String GetAfter( this String str, String value, Int32 startIndex = 0 )
        {
            str.ThrowIfNull(() => str);

            return GetAfter( str, value, startIndex, str.Length - startIndex );
        }

        /// <summary>
        ///     Gets the part of the string after the specified value, starting at the given start index
        ///     and ending after the specified number of characters.
        /// </summary>
        /// <exception cref="ArgumentNullException">The string can not be null.</exception>
        /// <exception cref="ArgumentNullException">value can not be null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The specified range is invalid.</exception>
        /// <param name="str">The input string.</param>
        /// <param name="value">The value to search.</param>
        /// <param name="startIndex">The start index of the string.</param>
        /// <param name="length">The length of the string, from the start index.</param>
        /// <returns>The string after the specified value.</returns>
        public static String GetAfter( this String str, String value, Int32 startIndex, Int32 length )
        {
            // ReSharper disable once AccessToModifiedClosure
            str.ThrowIfNull( () => str );
            value.ThrowIfNull( () => value );

            if ( startIndex < 0 || startIndex + length > str.Length )
                throw new ArgumentOutOfRangeException( "length", "The specified range is invalid." );

            str = str.Substring( startIndex, length );
            return !str.Contains( value )
                       ? String.Empty
                       : str.Substring( str.IndexOf( value, StringComparison.Ordinal ) + value.Length );
        }


        /// <summary>
        ///     Gets the part of the string after the specified value, starting at the given start index.
        /// </summary>
        /// <exception cref="ArgumentNullException">The string can not be null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The specified start index is invalid.</exception>
        /// <param name="str">The input string.</param>
        /// <param name="value">The value to search.</param>
        /// <param name="startIndex">The start index of the substring.</param>
        /// <returns>The string after the specified value.</returns>
        public static String GetAfter(this String str, Char value, Int32 startIndex = 0)
        {
            str.ThrowIfNull(() => str);

            return GetAfter(str, value, startIndex, str.Length - startIndex);
        }

        /// <summary>
        ///     Gets the part of the string after the specified value, starting at the given start index
        ///     and ending after the specified number of characters.
        /// </summary>
        /// <exception cref="ArgumentNullException">The string can not be null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The specified range is invalid.</exception>
        /// <param name="str">The input string.</param>
        /// <param name="value">The value to search.</param>
        /// <param name="startIndex">The start index of the string.</param>
        /// <param name="length">The length of the string, from the start index.</param>
        /// <returns>The string after the specified value.</returns>
        public static String GetAfter(this String str, Char value, Int32 startIndex, Int32 length)
        {
            // ReSharper disable once AccessToModifiedClosure
            str.ThrowIfNull(() => str);

            if (startIndex < 0 || startIndex + length > str.Length)
                throw new ArgumentOutOfRangeException("length", "The specified range is invalid.");

            str = str.Substring(startIndex, length);
            var valueIndex = str.IndexOf(value);
            return valueIndex < 0
                ? String.Empty
                : str.Substring(valueIndex + 1);
        }
    }
{'fraction_non_alphanumeric': 0.12006058102712377, 'fraction_numerical': 0.0035797879664050667, 'mean_word_length': 2.1623857205050063, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 110, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3865419', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1733, 'n_words': 619}