TriEngine  v0.0.16
General-purpose engine in C#/OpenGL
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
TriDevs.TriEngine.Extensions.StringExtensions Class Reference

Extensions for System.String More...

Static Public Member Functions

static string ReplaceFirst (this string s, string search, string replace, bool caseInsensitive=false)
 Returns a string in which the first occurrence of a specified string is replaced with another string. More...
 
static string Replace (this string s, string search, string replace, int count, bool caseInsensitive=false)
 Returns a string in which the N first occurrences of a specified string are replaced with another string. More...
 
static string Replace (this string s, string search, string replace, bool caseInsensitive=false)
 Returns a string in which all occurrences of a specified string are replaced with another string. More...
 

Detailed Description

Extensions for System.String

Member Function Documentation

static string TriDevs.TriEngine.Extensions.StringExtensions.Replace ( this string  s,
string  search,
string  replace,
int  count,
bool  caseInsensitive = false 
)
static

Returns a string in which the N first occurrences of a specified string are replaced with another string.

Parameters
sString to modify.
searchString to search for.
replaceString to replace the match(es) with.
countNumber of occurrences to replace.
caseInsensitiveTrue for case insensitive search, false for case sensitive.
Returns
The supplied string with the N first occurrences of the specified string replaced with the other.
56  {
57  var re = caseInsensitive ? new Regex(search, RegexOptions.IgnoreCase) : new Regex(search);
58  return re.Replace(s, replace, count);
59  }
static string TriDevs.TriEngine.Extensions.StringExtensions.Replace ( this string  s,
string  search,
string  replace,
bool  caseInsensitive = false 
)
static

Returns a string in which all occurrences of a specified string are replaced with another string.

This extension method supports case insensitive searches.

Parameters
sString to modify.
searchString to search for.
replaceString to replace the match(es) with.
caseInsensitiveTrue for case insensitive search, false for case sensitive.
Returns
The supplied string with all occurrences of the specified string replaced with the other.
73  {
74  var re = caseInsensitive ? new Regex(search, RegexOptions.IgnoreCase) : new Regex(search);
75  return re.Replace(s, replace);
76  }
static string TriDevs.TriEngine.Extensions.StringExtensions.ReplaceFirst ( this string  s,
string  search,
string  replace,
bool  caseInsensitive = false 
)
static

Returns a string in which the first occurrence of a specified string is replaced with another string.

Parameters
sString to modify.
searchString to search for.
replaceString to replace the match with.
caseInsensitiveTrue for case insensitive search, false for case sensitive.
Returns
The supplied string with the first occurrence of the specified string replaced with the other.
42  {
43  return Replace(s, search, replace, 1, caseInsensitive);
44  }

The documentation for this class was generated from the following file: