OP strings (v0.3)
In op strings are arrays of bytes. Tipically, arrays stores texts encoded in a local encode format but in
general strings can content binary data as images, sounds, ...
Creation
In op strings are created using quotes:
var s = "Native Big Data is the fastest Big Data platform ever created";s
Strings can be created form other objects:
var i = 12;
var number_12 = "" + i;number_12
Comparations
Comparation acts like other languajes. The following scripts will return true
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
var s_2 = "Native Big Data is the fastest Big Data platform ever " + "created";
s_1 == s_2
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
var s_2 = "Netive Big Data is the fastest Big Data platform ever " + "created";
s_1 < s_2
Searching and exploring data
The '[]' operator in strings is the best way to explore the data.
The length of a string can be obtained with the [] operator without parameters (or passing null) : The following scripts will return the length of the string:
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[]
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[null]
A byte from the string can be obtained with the [] operator with a number as parameter:
The following script will return the ascii code of the 'i' character:
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[3]
The '[]' operator with an array as a parameter acts as the 'substr' function in other languages:
The following script will return the substring between the 4 and 4+5 characters ('ve Bi') :
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[ [ 4, 5 ] ]
The following script will return the substring between the length - 10 and length -10 + 5 characters (' ever') :
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[ [ -10, 5 ] ]
The '[]' operator with a string as parameter acts as the 'indexOf' function in other languages:
This script will return 23
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[ "faste" ]
Searching with an array will search beginning a point different of the beginning. This script will return 8
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[ [ "i" ,4 ] ]
With a 2nd parameter as false the searching will begin at the end. This script will return 31
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[ [ "Big", false ] ]
With a 2nd parameter as true the searching will return an array of all matches. This script will return [ 7, 31 ]
var s_1 = "Native Big Data is the fastest Big Data platform ever created";
s_1[ [ "Big", false ] ]