Bug - Slice Function

Hello,

I ran into what appears to be a bug when using the Slice function. When I import data, in this case scores, it comes in the following format: W/L #-#. For example:

W 34-10
L 22-45
L 3-11

I am attempting to parse this data into three columns (a win/loss column, a points for column (the first number), and a points against column (the second number). When I attempt to use Slice for the win loss column, I tried the following formula:

=Slice([score data],1,1)

The idea is that this will show either “L” or “W”. But, if the first number is a single digit, it shows the entire result. In the above example, that means the Win/Loss Column would look like this:

W
L
L 3-11

Since this is a suggestion box and is tangentially related, the Split function in Coda does not allow multiple inputs like Sheets, which makes parsing out a number from scores more complex.

Love Coda - just want to put this on someone’s radar.

Hey @Joseph_B
I just tried your example and get an even worse result.

Really looks like a bug.

To solve your problem: You can use a regex_replace instead. It is complicated but very powerful. (I always use an online regex tester and fiddle around until it works :smiley: )

A simple one for your case:
=regexReplace([score data],"\W\d+","")

With \W you filter out all “non-word” characters like space and -, with \d+ you filter out one ore more digits (3, 10).

EDIT:
It works also if you use
=Slice([score data].toText(),1,1)

2 Likes

Thanks for double checking. And extra thanks for those workarounds. I used an IF statement, but this way may be cleaner.