Reputation: 343
i have the following text as String:
1. INTRODUCTION
Cerebral venous sinus thrombosis (CVST)
and i only need the second line as string, so i am using the below code
let SecondLine = unwords( tail (splitOn "\n" seccion))
but SecondLine is empty. Someone can help me?
Upvotes: 3
Views: 6525
Reputation: 2871
The easiest solution to dropping the first line is to uses lines
. It has the following signatures:
lines :: String -> [String] -- Splits string over newline character
You can therefore get the second line using:
let secondLine = head (tail (lines seccion))
Alternatively, you can use point-free style:
let secondLine = head . tail . lines $ seccion
Upvotes: 4
Reputation: 11940
Have you tried to use lines
?
let secondLine = (lines seccion) !! 1 in
Upvotes: 14