Sitecore 5.1.1 API

MainUtil.ReplacePostfix Method 

Replaces the postfix of a string.

[Visual Basic]
Public Shared Function ReplacePostfix( _
   ByVal s As String, _
   ByVal sFind As String, _
   ByVal sReplace As String _
) As String
[C#]
public static string ReplacePostfix(
   string s,
   string sFind,
   string sReplace
);

Parameters

s
A string.
sFind
The postfix to find.
sReplace
The replacement.

Return Value

A string with the postfix replaced.

Remarks

If the string does not end with the postfix, the string itself is returned.

Example

  string s0 = MainUtil.ReplacePostfix("Hello world", "world", "you"); // "Hello you"
  string s1 = MainUtil.ReplacePostfix("Hello world", "you", "me"); // "Hello world"

See Also

MainUtil Class | Sitecore Namespace | ReplacePrefix