# Text.SelectStr(Integer, Text) Method
> Version: _Available or changed with runtime version 1.0._
Retrieves a substring from a comma-separated string.
## Syntax
```al
NewString :=   Text.SelectStr(Number: Integer, CommaString: Text)
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
Number
Type: ../integer/integer-data-type
Specifies which substring to retrieve. The substrings in the comma-separated string are numbered 1, 2, 3, and so on. If Number is greater than the actual number of substrings, then a run-time error occurs.
CommaString
Type: text-data-type
A string that contains substrings separated by commas. The maximum length of this string is 391 characters.
## Return Value
NewString
Type: text-data-type
The substring from the comma-separated string at the index specified.
## Remarks
Any trailing commas are removed before the operation starts.
If Number is less than 1 or greater than the number of real values \(excluding trailing commas\) in the string, then an error is returned.
Quotes aren't supported. For example, a,b,"c,d",e is treated as a five-element substring where substring 4 is d".
## Example 1
```al
var
    CommaStr: Text[60];
    CommaStr2: Text[60];
    SubStr1: Text[60];
    SubStr2: Text[60];
    SubStr3: Text[60];
    SubStr4: Text[60];
    Text000: Label 'This,is a comma,separated,string';
    Text001: Label 'The calls to SelectStr return:\\';
    Text002: Label '11,22,33,,55,,,';
begin
    CommaStr := Text000;
    CommaStr2 := Text002;
    SubStr1 := SelectStr(2, CommaStr); // Pick out the 2nd substring.
    SubStr2 := SelectStr(4, CommaStr); // Pick out the 4th substring.
    SubStr3 := SelectStr(1, CommaStr2);
    SubStr4 := SelectStr(3, CommaStr2);
    Message(Text001 + '>%1<\' + '>%2<\' + '>%3<\' + '>%4<\', SubStr1, SubStr2, SubStr3, SubStr4);
end;
```
The message window displays the following text:
The calls to SelectStr return:
>is a comma\<
>string\<
>11\<
>33\<
## Example 2
```al
var
    CommaStr2: Text[60];
    SubStr5: Text[60];
    Text002: Label '11,22,33,,55,,,';
begin
    CommaStr2 := Text002;
    SubStr5 := SelectStr(6,CommaStr2);
    Message('>%1<\', SubStr5);
end;
```
This example returns an error.
## Related information
text-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-selectstr-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-selectstr-method/
