Page 1 of 1

How to remove/replace word wraps in a string?

Posted: 25 Mar 2015 14:13
by Patneu
Hello together,

sorry if this is a stupid question, but I just don't see how this should work:

I want to write a script, were I request a string from the user via the input() function and show him a multi-line textfield. There, he should enter some items of text, each of them seperated by a comma or on a new line. For me to further work with the string, I now want to replace all the word wraps (if any) with a comma, so that I have only one seperator left. If I try to do this

Code: Select all

regexreplace("<my input string>", chr(10), ",", 1)
it almost seems to work, at least I get my comma, but the word wrap is still there and my output (with "msg") looks like this:

Code: Select all

Hallo,
Hallo2
or this:

Code: Select all

Hallo
,Hallo2
but not like this:

Code: Select all

Hallo,Hallo2
:eh:

Maybe one of you has a clue at how to do this?
Thank you in advance for any suggestions. :)


P.S.: Sorry for anything written wrong or unclear, english is not my mother language.

Re: How to remove/replace word wraps in a string?

Posted: 25 Mar 2015 14:18
by admin
You probably need to replace CR (13) and LF (10). There is a handy variable for this in XY:

Code: Select all

regexreplace("<my input string>", <crlf>, ",", 1)
PS: Why regexreplace? This should do:

Code: Select all

echo replace("<my input string>", <crlf>, ",");

Re: How to remove/replace word wraps in a string?

Posted: 25 Mar 2015 14:24
by highend

Code: Select all

text regexreplace("<my input strings>", "\r?\n", ",");
Would be the "normal" way to do it (if there isn't a variable like "<crlf>".

Re: How to remove/replace word wraps in a string?

Posted: 25 Mar 2015 14:37
by Patneu
That's weird. I thought I already tried that... :oops: However, it works fine now. Thanks for your help. :D