Strip whitespace from a string/Top and tail: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(easylang)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(4 intermediate revisions by one other user not shown)
Line 221:
+ string_trim(" foobar "), newline)) FI
)</syntaxhighlight>
 
=={{header|Amazing Hopper}}==
<p>Amazing Hopper! Flavour "Jambo".</p>
<syntaxhighlight lang="Amazing Hopper">
#include <jambo.h>
 
Main
 
Set stack 25
c = "\t\t\n \n Message to triming\t\n \t"
Printnl ("Original Message: [", c,"]")
Set '"\n\n\UL\ENFNatural syntax:\n\n"', then bold off, and underline off
Set '"Right trim: [", c', Do right trim; then set '"]"'
Set '"\nLeft trim: [", c', Do left trim; Set '"]"'
Set '"\nAll trim: [", c', Do trim, now set '"]"' and print with newline
Underline( Bold( "\n\nFormal syntax:\n\n" ))
Printnl ( "Right trim: [", Rtrim(c),\
"]\nLeft trim: [", Ltrim(c),\
"]\nAll trim: [",Trim(c),"]\n" )
End
</syntaxhighlight>
{{out}}
<pre>
Original Message: [
Message to triming
]
 
 
Natural syntax:
 
Right trim: [
Message to triming]
Left trim: [Message to triming
]
All trim: [Message to triming]
 
 
Formal syntax:
 
Right trim: [
Message to triming]
Left trim: [Message to triming
]
All trim: [Message to triming]
 
</pre>
 
=={{header|AppleScript}}==
Line 597 ⟶ 653:
return 0;
}</syntaxhighlight>
 
==={{header|Gadget}}===
 
<p>Gadget C-library:
[https://github.com/DanielStuardo/Gadget Gadget C-library in Github]
</p>
<syntaxhighlight lang="c">
#include <gadget/gadget.h>
 
LIB_GADGET_START
 
Main
String r,s,t;
Stack{
Store ( r, Trim_r (Upper(" \n\t este mensaje será modificado " )) )
Store ( s, Trim_l (Reverse(Upper(" \n\t este mensaje será odasrever " ))) )
Store ( t, Trim (Upper(" \n\t este mensaje será modificado " )) )
}Stack_off
Print "Right Trim = [%s]\nLeft Trim = [%s]\nAll Trim = [%s]\n",r,s,t;
 
Free secure r,t, s;
End
</syntaxhighlight>
{{out}}
<pre>
Right Trim = [
ESTE MENSAJE SERÁ MODIFICADO]
Left Trim = [REVERSADO ÁRES EJASNEM ETSE
]
All Trim = [ESTE MENSAJE SERÁ MODIFICADO]
 
</pre>
 
=={{header|C sharp|C#}}==
Line 3,118 ⟶ 3,207:
=={{header|Wren}}==
In Wren 'whitespace' is defined as: space, tab, carriage return, and line feed characters. To trim off other non-printing characters such as form feed and vertical tab, you need to do a little more work.
<syntaxhighlight lang="ecmascriptwren">var a = " \t\r\nString with leading whitespace removed"
var b = "String with trailing whitespace removed \t\r\n"
var c = " \t\r\nString with both leading and trailing whitespace removed \t\r\n"
9,482

edits