The latest version for DAS is WSO2 Data Analytics Server 3.1.0. View documentation for the latest release.
WSO2 Data Analytics Server is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.

All docs This doc
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
||
Skip to end of metadata
Go to start of metadata

This extension provides basic string handling capabilities such as con-cat, length, convert to lowercase, replace all, etc. String extension can be used in a query as follows. Following are the functions of the String extension.

Char At function

Syntax<string> str:charAt(<string> str, <int>  index)
Extension TypeFunction
DescriptionReturns the char value as a string value at the specified index.
ExamplecharAt("WSO2", 1) returns 'S'.

 

Coalesce function

Syntax< int|long|float|double|string|boolean > str: coalesce (< int|long|float|double|string|boolean >  arg1, < int|long|float|double|string|boolean >   arg2 ,.., < int|long|float|double|string|boolean >   argN )
Extension TypeFunction
DescriptionReturns the value of the first of its input parameters that is not null.
ParametersThis functions accepts any number of parameters. The parameters can be of different types.
Return TypeThis is the same as the type of the first input parameter that is not null.
Examples
  • coalesce("123", null, "789") returns "123".
  • coalesce(null, "BBB", "CCC") returns "BBB".
  • coalesce(null, null, null) returns null 

 

Concatenation function

Syntax<string> str: concat   ( <int|long|float|double|string|boolean > arg1, < int|long|float|double|string|boolean >   arg2 ,.., < int|long|float|double|string|boolean >   argN )
Extension TypeFunction
DescriptionReturns a string that is the result of concatenating the given arguments:  arg1 arg2 , ..,  argN .
Examples
  • concat("D533", "8JU^", "XYZ") returns "D5338JU^XYZ".
  • concat("AAA", null, "CCC") returns "AAACCC".

 

Contains function

Syntax<bool> str: contains ( < string> inputSequence, <string>  searchingSequence )
Extension TypeFunction
DescriptionThis method returns true if  inputSequence  contains the specified sequence of char values in the  searchingSequence .
Examplecontains("21 products are produced by WSO2 currently", "WSO2") returns true.

 

Hexadecimal function

Syntax<string> str: hex   ( < string> str)
Extension TypeFunction
DescriptionReturns a hexadecimal string representation of  str .
Examplehex("MySQL") returns "4d7953514c".

 

Length function

Syntax<int> str: length   ( < string> str)
Extension TypeFunction
DescriptionReturns the length of the string:  str .
Exampleslength("Hello World") returns 11.

 

Lower Case function

Syntax<string> str: lower   ( < string> str)
Extension TypeFunction
DescriptionConverts the capital letters in the  str  input string to the equivalent simple letters.
Examplelower("WSO2 cep ") returns "wso2 cep ".

Regular Expression function

Syntax<boolean> str: regexp   ( < string> str, <string> regex )
Extension TypeFunction
DescriptionReturns true if the given string (i.e.  str ) matches the given regular expression (i.e.  regex  ). Returns false if the string does not match the regular expression.
Exampleregexp("WSO2 abcdh", "WSO(.*h)") returns true.

 

Repeat function

Syntax<string> str: repeat   ( < string> str, <int>  times)
Extension TypeFunction
DescriptionRepeats the specified string (i.e.  string ) for the specified number of times (i.e.  times ).
Examplerepeat("StRing 1", 3) returns "StRing 1StRing 1StRing 1".

 

Replace All function

Syntax<string> str: replaceAll   ( < string> str, <string>  regex ,  <string>  replacement)
Extension TypeFunction
DescriptionReplaces each substring of the given string (i.e.  str ) that matches the given regular expression (i.e.  regex ) with the string specified as the replacement (i.e.  replacement ).
ExamplereplaceAll("hello hi hello",  'hello', 'test') returns "test hi test".

 

Replace First function

Syntax<string> str: replaceFirst (< string>  str ,  <string>  regex ,  <string>  replacement )
Extension TypeFunction
DescriptionReplaces the first substring that matches the given regular expression (i.e.  regex ) with the string specified as the replacement (i.e.  replacement )
ExamplereplaceFirst("hello WSO2 A hello",  'WSO2(.*)A', 'XXXX') returns "hello XXXX hello".

 

Reverse function

Syntax<string> str: reverse   ( < string> str)
Extension TypeFunction
DescriptionReturns the reverse ordered string of  str .
Examplereverse("Hello World") returns "dlroW olleH".

 

Split function

Syntax<string> str: split ( <string> sourceString, <string> splitCharacter, <int> returnedOutputPosition )
Extension TypeFunction
DescriptionThis method splits the given  sourceString  by given  splitCharacter  and returns the string in the index given by  returnedOutputPosition .
Examplesplit("WSO2,ABM,NSFT", ",", 0) returns WSO2.

 

String Compare function

Syntax<int> str: strcmp ( < string> str, <string>  compareTo)
Extension TypeFunction
DescriptionCompares  str  with  compareTo  strings lexicographically.
Examples
  • strcmp("Hello", 'Hello') returns 0.
  • strcmp("AbCDefghiJ KLMN", 'Hello') returns -7.

 

Sub String function

Syntax<string> str: substr   ( < string> sourceText, <int> beginIndex )
Extension TypeFunction
DescriptionReturns a ne string that is a substring of  sourceText.
Examplesubstr("AbCDefghiJ KLMN", 4) returns "efghiJ KLMN".
Syntax<string> str: substr   ( < string> sourceText, <int> beginIndex,  <int> length )
Extension TypeFunction
Description Returns a new string that is a substring of  sourceText.
Examplesubstr("AbCDefghiJ KLMN",  2, 4) returns "CDef".
Syntax<string> str: substr   ( < string> sourceText, <string> regex)
Extension TypeFunction
Description Returns a new string that is a substring of  sourceText.
Examplessubstr("WSO2D efghiJ KLMN", '^WSO2(.*)') returns "WSO2D efghiJ KLMN" 
Syntax<string> str: substr   ( < string> sourceText, <string> regex,  <int> groupNumber )
Extension TypeFunction
DescriptionReturns a new string that is a substring of  sourceText.
Examplesubstr("WSO2 cep WSO2 XX E hi hA WSO2 heAllo",  'WSO2(.*)A(.*)',  2) returns " ello".

 

Trim function

Syntax<string> str: trim   ( < string> str)
Extension TypeFunction
DescriptionReturns a copy of  str , with the leading and/or trailing white-spaces omitted.
Exampletrim("  AbCDefghiJ KLMN  ") returns "AbCDefghiJ KLMN".

 

Unhexadecimal function

Syntax<string> str: unhex   ( < string> str)
Extension TypeFunction
DescriptionThis is the equivalent of the unhex function in mysql 5.0. unhex(str) interprets each pair of characters in str as a hexadecimal number. Also see hex () string extension.
Exampleunhex("4d7953514c") returns "MySQL".

 

Upper Case function

Syntax<string> str: upper ( <string> str)
Extension TypeFunction
DescriptionConverts the simple letters in the given input string (i.e.  str ) to the equivalent capital letters.
Exampleupper("Hello World") returns "HELLO WORLD".
  • No labels