In ACL language, how to remove line breaks in a characters string
In ACL language, how to remove line breaks in a characters string?
I try this command:
gsub("\r\n", "", $x);
But it doesn't work.
Can you help me?
In ACL language, how to remove line breaks in a characters string?
I try this command:
gsub("\r\n", "", $x);
But it doesn't work.
Can you help me?
The PTC technical support has solved the problem, see below.
The first parameter to the gsub() function is a regular expression string and that does not support C syntax like \r and \n for carriage return and line feed. Instead you would have to put that string in a variable and then use the variable as the parameter to the function.
$s = "\r\n";
gsub($s, ' ', $x);
Or you could take if further with the following:
$s = "one\r\ntwo"
gsub("\r\n", "x", $s)
If instead your string only has a \r or \n then the character class
gsub("[\r\n]", "x", $s)
would work. The first regular expression matches two characters whereas the second matches only one. The first result would have one 'x' but the second would have 'xx'.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.