Expression function split anomaly

Been meaning to ask this for a while, but there's a weird quirk when using split with filepaths with "" path separators where you have to use "\\\\" as the split text instead of just "\\" (noting that "" is the escape character, so the first one escapes the second resulting in a literal "". "\\" however would result in literal "\")

e.g.

split("c:\a\b\c\name.txt", "\\") # doesn't work
split("c:\a\b\c\name.txt", "\\\\") # does work

the former gives:
image

1 Like

Because backslashes are escape characters for the string constant and escape characters within regular expression syntax. So they have to be doubled in the raw string for each parser. Not an anomaly.

Microsoft's choice of the backslash as a directory separator back in the DOS days was seen back then as a "[expletive] you" to Unix. And is biting their own [expletive] now-a-days, along with their users' [expletive]s. Just say "NO" to Microsoft.

3 Likes