Ad space (banner)
๐ŸŸฃJulia Lessons
Lesson 20 / 68

Splitting and joining strings (split and join)

This lesson covers splitting and joining strings with Julia's split and join, with the aim of handling CSV-style data.

split() breaks a string into an array. Conversely, join() gathers an array into a single string. Both come up constantly when working with CSV-style data.

The sample code splits a comma-separated string into an array with split(csv, ",") and rebuilds it as a slash-separated string with join(fruits, " / "). Combining the two lets you change delimiters or strip stray spaces.

A common early stumble is the return type of split(). It gives you an array of SubString rather than plain strings, which restricts some string operations.

In professional work, this is a standard pairing that shows up whenever CSV files are read or logs are parsed.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Julia directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)