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.
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.
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 )
So, if there’s no line to break, Split() can’t really do its job here I guess …
I’ve added few fields to the doc you shared (thanks for sharing ) trying to find a workaround to your issue … and reproduced those in the sample you’ll find below
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() using something like :
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’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).