| StringHelperSplitTextAndNumber Method |
Splits a string that has an integer number as suffix (e.g. "text123") into its components.
Namespace: DigitalRune.TextAssembly: DigitalRune (in DigitalRune.dll) Version: 1.20.0.0 (1.20.1.14552)
Syntax public static void SplitTextAndNumber(
this string str,
out string text,
out int number
)
<ExtensionAttribute>
Public Shared Sub SplitTextAndNumber (
str As String,
<OutAttribute> ByRef text As String,
<OutAttribute> ByRef number As Integer
)
public:
[ExtensionAttribute]
static void SplitTextAndNumber(
String^ str,
[OutAttribute] String^% text,
[OutAttribute] int% number
)
[<ExtensionAttribute>]
static member SplitTextAndNumber :
str : string *
text : string byref *
number : int byref -> unit
Parameters
- str
- Type: SystemString
A string that has an positive integer number as suffix. The suffix is optional. Examples:
"text", "text123".
- text
- Type: SystemString
The text before the number suffix. "" if str is or
empty.
- number
- Type: SystemInt32
The positive integer number. -1 if str does not contain a suffix.
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
This method should only be used if str contains only letters and digits.
If str contains characters other than letters and digits the result is
undefined.
Here is a list of examples:
Input | Output |
---|
| "", -1 |
"" | "", -1 |
"text" | "text", -1 |
"123" | "", 123 |
"text123" | "text", 123 |
"123text" | "123text", -1 |
"123text456" | "123text", 456 |
See Also