Split Text

Verb: splitString

Splits a text based on a delimiter and limit the number of subtexts, returning them as elements of a "Text" list.

Syntax

splitString --text(String) --delimiteroption(DelimiterOptions) --standarddelimiter(Nullable<StandardDelimiters>) --customdelimiter(String) --count(Numeric) -- limit(Numeric) [--isregularexpression(Boolean)] --length(Numeric) (List<String>)=value

Inputs

Script Designer Required AcceptedTypes Description
--text Text to split Required Text Text to split based on the Demiliter type and Maximum number of subtexts.
--delimiteroption Delimiter type Required DelimiterOptions Type of delimiter to use as basis for splitting the elements of Text to split. The available options are:
  • Custom delimiter
  • Length Delimiter
  • Standard delimiter
  • --standarddelimiter Standard delimiter Only whenDemiliter type is StandardDelimiter StandardDelimiters Spacings that serve as a delimiter to define the parts where the text should be split. You can select an option from the ones listed below:
  • Space;
  • Tab;
  • New line.
  • --customdelimiter Custom delimiter Only whenDemiliter type is CustomDelimiter Text Custom delimiter, which can be a character, phrase, text, or regular expression to use as an anchor to define the parts where the text should be split.
    --count Maximum number of subtexts Optional Number Maximum number of divisions possible for Text to split.
    --limit Limit of subtexts Required Number The number of the first occurrences of division to parameter Text to split.
    --isregularexpression Use regular expression Optional Boolean When enabled, allows the use of regular expressions.
    --length Length Only whenDemiliter type is LengthDelimiter Number Number of characters used to define the parts into which the text should be split.

    Outputs

    Script Designer AcceptedTypes Description
    value Text list List<Text> "Text" type List that stores in its elements the subtexts obtained from the text split.

    Example

    Example 1: Splits the words in the text by applying the standard delimiter Space, and returns a list with the split elements.

    defVar --name textToSplit --type String --value "Quantum computing is a type of computation whose operations can harness the phenomena of quantum mechanics."
    defVar --name subTextList --type List --innertype String
    //Split the text "Quantum computing is a type of computation whose operations can harness the phenomena of quantum mechanics." by applying the delimiter "Space".
    splitString --text "${textToSplit}" --delimiteroption "StandardDelimiter" --standarddelimiter "Space" subTextList=value
    logMessage --message "${subTextList}" --type "Info"
    //This example produces the following output: [Quantum,computing,is,a,type,of,computation,whose,operations,can,harness,the,phenomena,of,quantum,mechanics.]
    

    Example 2: Splits the words in the text by applying the custom delimiter "-", and returns a list of elements generated by the split.

    defVar --name textToSplit --type String --value "IBM-automation"
    defVar --name maximumSplits --type Numeric --value 2
    defVar --name subTextList --type List --innertype String
    defVar --name customDelimiter --type String --value "-"
    //Split the text "IBM-automation" by applying the custom delimiter "-".
    splitString --text "${textToSplit}" --delimiteroption "CustomDelimiter" --customdelimiter "${customDelimiter}" --limit ${maximumSplits} subTextList=value
    logMessage --message "${subTextList}" --type "Info"
    //This example produces the following output: [IBM,automation]
    

    Example 3: Splits the words in the text by applying the delimiter by length set to "10", and returns a list of elements generated by the split.

    defVar --name textToSplit --type String --value "Quantum computing is a type of computation whose operations can harness the phenomena of quantum mechanics."
    defVar --name maximumSplits --type Numeric --value 2
    defVar --name splitSize --type Numeric --value 10
    defVar --name subTextList --type List --innertype String
    //Split the text "Quantum computing is a type of computation whose operations can harness the phenomena of quantum mechanics." by applying the delimiter by length set to 10.
    splitString --text "${textToSplit}" --delimiteroption "LengthDelimiter" --length ${splitSize} --limit ${maximumSplits} subTextList=value
    logMessage --message "${subTextList}" --type "Info"
    //This example produces the following output: [Quantum co,mputing is]
    

    Remarks

    Custom delimiter:

  • IBM RPA Studio only interprets it as a regular expression if the Use regular expression parameter is enabled;
  • The Split Text command is case-sensitive.
  • If the Limit of subtexts parameter value is less than the occurrences of the separator, the remaining part of the text is ignored.

    See Also

  • Add Escape Characters to Regular Expression
  • Add Escape Characters to Text
  • Calculate Hash
  • Change Text Case
  • Check File
  • Concatenate Texts
  • Convert HTML to Text
  • Count Occurrences in Text
  • Count Text Characters
  • Create Random Text
  • Create Table By Regular Expression
  • Empty or Null Text Variable
  • Find by Regular Expression
  • Find Occurrences in Text
  • Format Text
  • Get Subtext
  • Get Text from Regular Expression
  • HTML to Markdown
  • Insert New Line to Text
  • Join Text
  • Pad Text
  • Parse URI
  • Remove Diacritics
  • Remove Escape Characters
  • Replace Part of Text
  • Replace Text
  • Trim Text Blanks