cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1546
Views
4
Helpful
4
Replies

Split string on newline

rruckley
Level 1
Level 1

G'day,

I'm writing a process that takes as input a multiline string. I need to chop this string up via newlines and iterate through each one but I can't work out how to split a string based on newlines and the TEO Reference Guide is suitably vague on what special characters (if any) one can split a string on .

This process is intended to be initiated directly via TEOWebConsole at this stage else I would implement this in CCP instead.

Thoughts?

1 Accepted Solution

Accepted Solutions

Shaun Roberts
Cisco Employee
Cisco Employee

You can use the regex ^.*$

and then feed in the string and then loop through it, trim off the ends and go from there.

I have a TAP of some commonly used functions that I use in many of my automations. I call it the Automation Function Tools. I have uploaded the zipped tap to here. Download it, unzip, and import.

It has a function called convert multi-line to single-line string. While that might not be exactly what you are doing, you can pull the pieces out for the breaking at newline and be ok I think.

Here's a screenshot of what I mean:

--shaun

--Shaun Roberts
Principal Engineer, CX
shaurobe@cisco.com

View solution in original post

4 Replies 4

Shaun Roberts
Cisco Employee
Cisco Employee

You can use the regex ^.*$

and then feed in the string and then loop through it, trim off the ends and go from there.

I have a TAP of some commonly used functions that I use in many of my automations. I call it the Automation Function Tools. I have uploaded the zipped tap to here. Download it, unzip, and import.

It has a function called convert multi-line to single-line string. While that might not be exactly what you are doing, you can pull the pieces out for the breaking at newline and be ok I think.

Here's a screenshot of what I mean:

--shaun

--Shaun Roberts
Principal Engineer, CX
shaurobe@cisco.com

Chris,

     Thats excellent news. I was hoping the split string could understand special characters like tab and newline but a regex works fine for me. I even tried passing the string to a powershell script but of course multiline strings aren't supported with powershell!

     I'm guessing if I rename the extension to your attachement as .tap then I should be able to import that directly?

     Otherwise, my is ryan.ruckley@alphawest.com.au

     Thanks.

Ryan

Ryan,

It's a TAP file inside of a zip. Show extract the TAP from the zip using your favorite .zip extracter then you should be able to import.

--shaun

--Shaun Roberts
Principal Engineer, CX
shaurobe@cisco.com

Chris,

Cheers got it.

Ryan

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: