StringExtensions.GetStringBetween Method

CSharp Extensions

StringExtensionsGetStringBetween Method
Get a substring that starts from a specific string and ends to a specific string.

Namespace: CSharpExtensions
Assembly: CSharpExtensions (in CSharpExtensions.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static string GetStringBetween(
	this string input,
	string startString,
	string endString,
	int startFrom = 0
)
<ExtensionAttribute>
Public Shared Function GetStringBetween ( 
	input As String,
	startString As String,
	endString As String,
	Optional startFrom As Integer = 0
) As String
public:
[ExtensionAttribute]
static String^ GetStringBetween(
	String^ input, 
	String^ startString, 
	String^ endString, 
	int startFrom = 0
)
[<ExtensionAttribute>]
static member GetStringBetween : 
        input : string * 
        startString : string * 
        endString : string * 
        ?startFrom : int 
(* Defaults:
        let _startFrom = defaultArg startFrom 0
*)
-> string 

Parameters

input
Type: SystemString
A string to be extracted value from.
startString
Type: SystemString
A substring from where the result starts.
endString
Type: SystemString
A substring to where the result ends.
startFrom (Optional)
Type: SystemInt32
A zero-based position from where the result starts.

Return Value

Type: String
The extracted substring.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
If invalid parameter is passed an empty string is returned.
See Also