Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Teams
, (opens new window)

One Appfire Support Knowledge Base
Results will update as you type.
  • License-related documentation
  • Product Categories
    • Administrative Tools
    • BI and Reporting Apps
    • Publishing
    • Agile
    • Document Management
    • ITSM
    • Developer Tools
    • Workflow & Automation
      • Jira Misc Custom Fields
      • JMWE for Jira Server and Data Center
      • JMWE for JIRA Cloud
      • Power Scripts for Confluence
      • Power Scripts Knowledge Base
        • Scripting Best Practices
        • Troubleshooting Power Scripts
        • Scripting Basics
        • Live Fields Articles
        • Finding Kepler Home and SIL Templates
        • Code Snippets
          • Converting Milliseconds to Days
          • Creating a Sum of Custom Field Values
          • Creating a Table in the Description
          • JSONifying a String with Unusual Dimensions
          • Preparing Data for Use with lfRestrictSelectOptions()
          • Preventing an Epic from Closing Until All Children Are Closed
          • Prevent Sub-task Creation in Jira Cloud
          • Running Scripts Via REST
          • Using HTML with sendEmail()
          • Using the split() Routine
          • Working with JSON Data
          • Chaining Filters in a Jira Expression
          • Using AJAX to Hide Issue Links
          • Retrieving Data From a Separate File
          • Using Atlassian Wiki Markup to Create a Table in the Description
          • Using the Jira Announcement Banner on Screens Where Live Fields is not Supported
          • Bulk user account deactivation (last-login-based)
          • How to fetch the fixVersions ID from an issue using SIL routines and the JVersion structure
          • Select List (single choice) options description+id in Power Scripts using SIL Groovy Connector/Runner
        • Common REST Service Security Settings
        • REST, cURL and Postman
        • How to set admin token in Power Apps
        • LDAP configuration settings for SSL connections in Power apps config
      • JQL Search Extensions for Jira
      • JSU Automation Suite for Jira Workflows- Server / Data Center
      • JSU Automation Suite for Jira Workflows - Cloud
      • Autowatch for Jira
      • Power Database Fields PRO Knowledge Base
      • Scripting for Confluence (SCRP)
      • JIRA Command Line Interface (CLI) (JCLI)
      • Update on Transition for JIRA (CW)
      • UPM Command Line Interface (CLI) (UPMCLI)
      • Service Desk Command Line Interface (CLI)
      • Tempo Command Line Interface (CLI)
      • Bitbucket Command Line Interface (CLI)
      • Create on Transition for JIRA (CSOT)
      • Confluence Command Line Interface
      • Run CLI Actions in Confluence (CCLI)
      • Bamboo Command Line Interface (CLI) (BCLI)
      • Run CLI Actions in JIRA (JCLIP)
      • Clone Plus for JIRA (JCPP)
      • Run CLI Actions in Bamboo (BCLIP)
      • Atlassian Command Line Interface (CLI) (ACLI)
      • Agile Command Line Interface (CLI) (AGILECLI)
      • How to retrieve debug logs for Clone Plus for Jira, Create on Transition, and Update on Transition apps in Jira
    • Integrations KB's
  • Migration Support
  • General Articles
  • KB [KBS]
  • Mohami Support Knowledge Base [SUPPORTM]
    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Using the split() Routine
    Published Nov 21, 2022

    Using the split() Routine

    Many support requests come from users who want to do some kind of text parsing. One of the most effective (and easiest!) ways of parsing scripts is by using the split() routine.

    Splitting a Multiline Text Custom Field

    Let's say you want to get the value of the third line a multiline text field. At first, this may seem difficult but not if we use the split() routine. For example:

    string [] textLines = split(#{textFieldMultiLine}, "\\u000A"); string thirdLine = textLines[2];

    As you can see by the above code that we can split up the lines by telling the SIL interpreter to look for the line feed unicode (\u000A). Since our escape character is embedded inline, we use two escape characters. 

    For a complete list of unicode characters, see this Wikipedia article:

    List of Unicode characters

    String Concatenation

    Let's say you wanted to join all lines of our hypothetical multiline text field. You can either loop through all the elements and append each element together, or you can cheat and use the replace() routine.

    string [] textLines = split(#{textFieldMultiLine}, "\\u000A"); string allTogether = replace(textLines, "|", "");

    All this does is replace pipe separators found in an array with an empty string. The same thing can be accomplished by using the join() routine:

    string [] textLines = split(#{textFieldMultiLine}, "\\u000A"); string allTogether = join(textLines, " ");

    Splitting a Table in Confluence

    A user was kind enough to post an example of how he split values in a table in Confluence.

    number pageId = getPage("DEMO", "table example"); string [] tabletext = split(pageId.content, "table>"); string [] tables;     int i; int j=0; for(i=0; i<size(tabletext); i++){     if(contains(tabletext[i],"<tbody>")){         tables[j] = "<table>" + tabletext[i] + "table>";         j++;     } }

    As you can see, using the split() routine can be used to parse text in surprising (yet effective) ways.

    Additional Help

    Need help implementing this script? Talk to me directly to me by clicking on the bot on this page. 

    Related articles

    Filter by label

    There are no items with the selected labels at this time.

    {"serverDuration": 13, "requestCorrelationId": "79483837f83d4d8f97253a3fffc05214"}