user2012677 user2012677 - 9 months ago 37
Ruby Question

ruby .split('\n') not splitting on new line

Why does this string not split on each "\n"? (RUBY)

"ADVERTISING [7310]\n\t\tIRS NUMBER:\t\t\t\t061340408\n\t\tSTATE OF INCORPORATION:\t\t\tDE\n\t\tFISCAL YEAR END:\t\t\t0331\n\n\tFILING VALUES:\n\t\tFORM TYPE:\t\t10-Q\n\t\tSEC ACT:\t\t1934 Act\n\t".split('\n')


You need .split("\n"). String interpolation is needed to properly interpret the new line, and double quotes are one way to do that.