Anyone know how to split a string by line break?

Started by jvdw007, March 28, 2019, 21:58:44

Previous topic - Next topic

jvdw007

As the title says, I'm trying to split a long string from a csv file by the line breaks.
Looked at the example banana files and the older monkey docs but not finding anything that says how to use special chars like line breaks.
Tried thestring.split("\r\n"), thestring.split(chr(10)) (and other variants like chr$(10) char$(10) etc and none work.

If this is not possible, maybe I can read the file in line-by-line instead I guess?

Thanks,
Jaco
Retro gaming fan and maker sometimes...

Derron

There is not just "\r\n" - maybe have a closer look in Notepad++ (or so) and let you display line endings so you see if it is CR/LF or just LF or ...

In BlitzMax the newline char is escaped as "~n" - assume this is the same in Monkey-X/Cerberus.


bye
Ron

jvdw007

Hey Ron,

Thanks a load for that. I never used blitzmax so wasn't aware. Saying that, I tried it and it worked! Happy days!  ^-^
Retro gaming fan and maker sometimes...

GW

I usually first try:  String.Replace("~r","").Split("~n")

jvdw007

Retro gaming fan and maker sometimes...