Method StripPrefix
StripPrefix(String, String)
If value
ends with prefix
then returns a new string without the prefix, otherwise returns value
.
Declaration
public static string StripPrefix(this string value, string prefix)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to strip the prefix from. |
System.String | prefix | The prefix to be stripped. |
Returns
Type | Description |
---|---|
System.String | Either a new string without the specified prefix, or else the original string. |
Remarks
This overload is case sensitive. For a case insensitive version use StripPrefix(String, String, Boolean) with ignoreCase set to true.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Throw if either |
StripPrefix(String, String, Boolean)
If value
ends with prefix
then returns a new string without the prefix, otherwise returns value
.
Declaration
public static string StripPrefix(this string value, string prefix, bool ignoreCase)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to strip the prefix from. |
System.String | prefix | The prefix to be stripped. |
System.Boolean | ignoreCase | A boolean indicating whether or not to match the prefix in a case sensitive (true) or insensitive (false) manner. |
Returns
Type | Description |
---|---|
System.String | Either a new string without the specified prefix, or else the original string. |
Remarks
This overload is case sensitive. For a case insensitive version use StripPrefix(String, String, Boolean) with ignoreCase set to true.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Throw if either |