StrExtract
- extracts given item (substring) from comma-separated string

String manipulation
(AFL 2.4)


SYNTAX StrExtract( list, item, separator = ',' )
RETURNS STRING
FUNCTION Extracts given item (substring) from comma-separated list of items. item is a zero-based index of the item in the list (see also note below).

If no substring at given index is found then empty string is returned ("").

Useful to retrive symbols from the list obtained via GetCategorySymbols function.

New in AmiBroker version 5.20:
StrExtract( "string", item ) now accepts negative item values allowing to address items counting from the END of the list

New in AmiBroker version 5.90:
separator parameter allows to define separator other than comma

EXAMPLE StrExtract( "MSFT,AAPL,AMD,INTC", 2 );// will return AMD

StrExtract( "MSFT,AAPL,AMD,INTC", 0 );// will return MSFT

StrExtract( "MSFT,AAPL,AMD,INTC", 200 );// will return empty string ""


//
// The example below shows how to use negative item
// references (Version 5.20 AND up only!)

tickers =
"AAPL,MSFT,INTC";

"The last item is " + StrExtract( tickers, -1 );
printf("listing from the end of the list:n");

for( item = -1; ( sym = StrExtract( tickers, item ) ) != ""; item-- )
{
  
printf( sym + "n" );
}
SEE ALSO GETCATEGORYSYMBOLS() function

References:

The StrExtract function is used in the following formulas in AFL on-line library:

More information:

Updated on-line reference