Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

Split string on newline

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
Cisco Employee

Re: Split string on newline

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 shaurobe@cisco.com CIAC Adoption Pilot Engineering Lead
4 REPLIES
Cisco Employee

Re: Split string on newline

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 shaurobe@cisco.com CIAC Adoption Pilot Engineering Lead
Community Member

Re: Split string on newline

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

Cisco Employee

Split string on newline

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 shaurobe@cisco.com CIAC Adoption Pilot Engineering Lead
Community Member

Split string on newline

Chris,

Cheers got it.

Ryan

195
Views
4
Helpful
4
Replies
CreatePlease to create content