Skip to Content
Learn Red ? Fundamentals of Red
book

Learn Red ? Fundamentals of Red

by Ivo Balbaert
May 2018
Beginner content levelBeginner
252 pages
6h 19m
English
Packt Publishing
Content preview from Learn Red ? Fundamentals of Red

Splitting a string – split

You can split a string on spaces, or on other characters, or even on strings - all these are called the delimiter, and the result of the split is a series. Here are some examples of this:

;-- see Chapter05/strings-as-series.red:s1: "The quick brown fox jumps over the lazy dog"split s1 " " ;== ["The" "quick" "brown" "fox" "jumps" "over" "the" "lazy" "dog"]s2: "bracadabra"split s2 "a" ;== ["br" "c" "d" "br"]s3: "abracadabra"split s3 "a" ;== ["" "br" "c" "d" "br"]

From the last line, you can see that if the string starts with the delimiter, the first split item that will be found is an empty string "". The split word is very useful in the analysis and processing of text files.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How I Built a Personal Board of Directors With GenAI

How I Built a Personal Board of Directors With GenAI

Vipin Gupta
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally
Why AI Demands a New Breed of Leaders

Why AI Demands a New Breed of Leaders

Faisal Hoque, Thomas Davenport, Erik Nelson

Publisher Resources

ISBN: 9781789130706Supplemental Content