Languages & Coding > Monkey

Anyone know how to split a string by line break?

(1/1)

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

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!  ^-^

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

jvdw007:
Thanks for the tip GW!

Navigation

[0] Message Index

Go to full version