Read Until - CSharp System

CSharp examples for System:String SubString

Description

Read Until

Demo Code

// file, You can obtain one at http://www.apache.org/licenses/
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   w  w w.  j av a2 s . c o  m

public class Main{
        public static string ReadUntil(this string searchIn, string searchFor, ref int pos) {
			StringBuilder sb = new StringBuilder();

			while (pos < searchIn.Length - searchFor.Length) {
				if (searchIn.Substring(pos, searchFor.Length) == searchFor) {
					return sb.ToString();
				}

				sb.Append(searchIn[pos]);
				pos++;
			}

			// Didn't find it.
			return null;
		}
}

Related Tutorials