Linebreak() behavior changed?

I have a doc where I use split(linebreak()) to split up the lines of a chunk of text into a list, but it seems to no longer be functioning the way it used to.

I’ve created a test doc here to demonstrate the problem. Previously when I would input text similar to what is currently in first row of this doc, I would get the lines split up in the second column, but it’s no longer working.

Am I missing something? Is there some other way to achieve what I want here? I tried splitting by character (10) and character (13) thinking maybe it was a difference between a hard and soft line break, but neither of those work either.

@Aaron_Moritz what would/did Row One, Column 5 look like?

I want each line to be split into a separate list item. I added a third column called ‘expected output’ to show what this looks like. I achieved it in that column by manually typing a comma after each row, and splitting by comma rather than linebreak.

Hi @Aaron_Moritz :blush:

I’m not entirely sure of what I’m going to say but I think Coda takes your Input not as a multiline string but as a whole string displayed as a multiline one (if that makes any sense :sweat_smile: )
So, if there’s no line to break, Split() can’t really do its job here I guess :woman_shrugging:

I’ve added few fields to the doc you shared (thanks for sharing :raised_hands: ) trying to find a workaround to your issue :blush: … and reproduced those in the sample you’ll find below :blush:

I think the easiest way to Split() your Input according to your needs would be to use RegexReplace() to convert any apparent (“visual”) line breaks into LineBreak() which you can then Split() :blush: using something like :

thisRow.Input.RegexReplace("\r\n",LineBreak()).Split(LineBreak())

Where the Regular Expression "\r\n" will match any carriage return (the equivalent to Character(13)) and newline (the equivalent to Character(10))

Or even this one apparently …

thisRow.Input.RegexReplace("\R",LineBreak()).Split(LineBreak())

Where the Regular Expression "\R"

(See the fields [1 - Split Input] and [2 - Split Input] the sample below or the field [Split Input] in the doc you shared)

Or, a little bit cumbersome, manually add line breaks into your input maybe …

I mean, I don’t know how you actually get your Input (if it’s a simple manual input or not) but by adding new lines there, Split() still seems to work :blush:

(See [Input 2] and [Split Input 2] either in the doc you shared or in the sample)

Hope this helps :innocent:
(Even though it doesn’t quite answer your question)

2 Likes

so the answer is YES

coda HAS changed the behaviour of the Split(LineBreak()) combination!
and it has BROKEN a LOT of my clients documents.

basically, they decided to introduce TWO types of line-breaks generated by LineBreak();

  • the HARD line-break which occurs between paragraphs, generated by LineBreak(FALSE)
  • the SOFT line-break which separates lines without creating a new paragraph, by LineBreak(TRUE)

BUT - alas - the Split(LineBreak(TRUE)) and Split(LineBreak(FALSE)) behave exactly the same…
they only split your text on the HARD line-breaks and ignore the soft line breaks!

so, as @Pch has indicated above (bravo!), you need to replace the soft line-breaks with hard line-breaks first, and then use the Split(LineBreak()) to split your text into lines as you wanted to do.

the RegexReplace(‘\R’,LineBreak()) scans for ANY type of line-break and replaces it with the hard line-break. so your Split(LineBreak()) then does exactly what you wanted it to do.

in the regex language \R stands for “any-line-break”

the sample table below shows how the three options behave (using three blocks of text)…
i have used the numbered-list format for the outputs, so we can see clearly how they split

i hope this makes the issue and the solution clearer

max

3 Likes

Thanks for the replies!

I’ve been able to get my original doc working the way I want using the regex trick. And knowing that linebreak() now accepts true and false parameters will actually be useful for a few other things I’m doing (even if it doesn’t work properly with split() yet).

2 Likes