Login
|
Signup
langref.org
-
ruby
,
cpp
,
fsharp
,
erlang
...
add..
all
clojure
fantom
go
groovy
java
ocaml
perl
php
python
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Strings
Manipulation
Remove leading and trailing whitespace from a string
Given the string
" hello "
return the string
"hello"
.
ruby
puts " hello ".strip
puts " hello ".strip
ruby
" hello ".strip!
" hello ".strip!
cpp
C++/CLI .NET 2.0
String^ s = " hello "; String^ trimmed = s->Trim();
using namespace System;
int main()
{
String^ s = " hello "; String^ trimmed = s->Trim();
System::Console::WriteLine("|{0}|{1}|", s, trimmed);
}
fsharp
let s = " hello "
let trimmed = s.Trim()
#light
open System
let s = " hello "
let trimmed = s.Trim()
printfn "|%s|%s|" s trimmed
fsharp
let trimmed = " hello ".Trim()
#light
open System
let trimmed = " hello ".Trim()
printfn "|%s|" trimmed
erlang
Trimmed = string:strip(S),
-module(trim).
-export([start/0]).
start() ->
S = " hello ",
Trimmed = string:strip(S),
io:format("|~s|~s|~n", [S, Trimmed]).
csharp
string str = " hello ";
str = str.Trim();
Console.WriteLine(str);
class SolutionXX
{
static void Main()
{
string str = " hello ";
str = str.Trim();
Console.WriteLine(str);
}
}
haskell
unwords (words " hello ")
unwords (words " hello ")
Submit a new solution for
ruby
,
cpp
,
fsharp
,
erlang
...
There are 14 other solutions in
additional
languages (
clojure
,
fantom
,
go
,
groovy
...)