String.split("pattern")

Tinderbox Icon


Operator Type:   Function
Operator Scope of Action:   Item
Operator Purpose:   Data manipulation

String.split("pattern")

New to v5.7.1, this operator splits a string into a list, as divided by instances of pattern in the original string. Source characters forming part of pattern are not passed to the list. The source string itself is not affected.

pattern is one of:

The result of the operator is a List-type attribute value, i.e. the data should be passed to a list. Passing the output to s Set-type attribute will de-dupe any list values in the output with the first instance of any duplicates forming its set entry.

For example:

$MyList = "ant bee ant cow".split(" ") gives "ant;bee;ant;cow"

$MySet = "ant bee ant cow".split(" ") gives "ant;bee;cow"

$MyList = "ant, bee, cow".split("\W+ ") gives "ant;bee;cow"

$MyList = "ant, bee, cow".split(" ") gives "ant,;bee,;cow"

$MyList = $MyString.split($MyString(agent)) 

$MyList = $MyString(parent).split("and") 

Useful pattern values are "\W+" and "\.". The first splits the source at word boundaries removing spaces and punctuation. The second divides on sentences ending with a period - it will strip the terminating punctuation but not that within the sentence.


Possible relevant notes (via "Similar Notes" feature):

Up: Full Operator List
Previous: String.size  Next: String.substr(startN[,lengthN]) 

A Tinderbox Reference File : Actions & Rules : Operators : Full Operator List : String.split("pattern")

Quicklinks: Attributes | Action Codes | Export Codes | Designators | Date Formats | aTbRef Site Map

[Last updated: 16 May 2012, using v5.11.1]


Search:

Google search aTbRef for:  


Creative Commons Licence

aTbRef by Mark Anderson is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

[See aTbRef CC licence Attribution & Waiver info]

Made with Tinderbox