Sitecore 5.0 API

MainUtil.ReplacePrefix Method 

Replaces the prefix of a string.

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

Parameters

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

Return Value

A string with the prefix replaced.

Remarks

If the string does not start with the prefix, the string itself is returned.

Example

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

See Also

MainUtil Class | Sitecore Namespace | ReplacePostfix