Title: Search Strings
Slug: search_strings
Summary: Search Strings Using Scala.
Date: 2017-01-03 12:00
Category: Scala
Tags: Basics
Authors: Chris Albon

If you want a deeper guide to Scala, when I was learning I used Programming Scala and Scala for Data Science.

Create A String


In [25]:
// Create a value called text that is a string
val text: String = "This is a sentence that we want to split along every space"


Out[25]:
Array(This, is, a, sentence, that, we, want, to, split, along, every, space)

Split Up A String By Commas


In [27]:
// Create a value called csv_row that is a string and contains one row of data
val csv_row: String = "Billy, Miller, 22, Baker, High School"

// Split up that row by commas
csv_row.split(",")


Out[27]:
Array(Billy, " Miller", " 22", " Baker", " High School")