Replace

Input:
string (UTF-8)
Output:
String, where all symbols, that equal to the first symbol are replaced to the last symbol.

IN

test

OUT

test

IN

tttts

OUT

sssss

IN

Hello

OUT

oello

IN

HelloHellohello

OUT

oellooellohello

IN

1337

OUT

7337

IN

hello, haxor! how are you?

OUT

?ello, ?axor! ?ow are you?

IN

-string-replace-test-$

OUT

$string$replace$test$$

IN

hi, khozov!

OUT

!i, k!ozov!
Login to submit solution


6 symbols pyth
Mon Sep 19 14:17:52 2016 Sait2000
:zhzez
20 symbols perl
Mon Oct 6 14:00:39 2014 vakorol
#!/usr/bin/perl -paF
s/$F[0]/$F[-1]/g
22 symbols ruby2.0
Mon Oct 6 15:01:25 2014 fl00r
#!/usr/bin/ruby2.0 -p
$_.gsub!$_[0],$_[-1]
24 symbols ruby2.0
Sun Oct 5 19:41:24 2014 fl00r
#!/usr/bin/ruby2.0 -p
$_.gsub!($_[0],$_[-1])
26 symbols perl
Thu Oct 2 13:41:38 2014 vakorol
#!/usr/bin/perl -p
/.$/;$r=$&;/./;s/$&/$r/g
30 symbols ruby2.0
Sun Oct 5 19:41:06 2014 fl00r
#!/usr/bin/ruby2.0 -p
$_.gsub!($_[0],$_.chomp[-1])
31 symbols perl
Tue Oct 14 00:29:29 2014 maxymania
#!/usr/bin/perl -p
m'^(.).*(.)$';$a=$2;s,$1,$a,g
33 symbols bash
Tue Jul 26 18:07:55 2016 hidefromkgb
t=`cat`;tr ${t:0:1} ${t: -1}<<<$t
36 symbols perl
Sun Aug 3 02:38:05 2014 danieljabailey
#!/usr/bin/perl -n
/^(.).*(.)$/;$a=$2;s/$1/$a/g;print
37 symbols perl
Wed Jul 30 01:45:36 2014 danieljabailey
#!/usr/bin/perl -n
m/^(.).*(.)$/;$a=$2;s/$1/$a/g;print
38 symbols python3
Fri Aug 1 16:42:56 2014 PixelIndigo
s=input()
print(s.replace(s[0],s[-1]))
38 symbols python3
Sat Aug 9 00:42:42 2014 z423x5c6
a=input()
print(a.replace(a[0],a[-1]))
41 symbols python2
Mon Aug 4 17:37:47 2014 LLcoolNJ
w=raw_input()
print w.replace(w[0],w[-1])
41 symbols python2
Fri Aug 8 02:36:01 2014 PFischbeck
s=raw_input()
print s.replace(s[0],s[-1])
41 symbols perl
Tue Sep 16 03:06:56 2014 maxymania
$_=<>;m'^(.).*(.)$';$a=$2;s,$1,$a,g;print
42 symbols python2
Fri Aug 8 02:34:13 2014 PFischbeck
s=raw_input()
print s.replace(s[0],s[-1])
44 symbols python3
Wed Jul 30 15:19:48 2014 vik
s=input()
print(s.replace(s[0],s[len(s)-1]))
48 symbols python3
Tue Sep 16 03:10:51 2014 maxymania
(lambda s:print(s.replace(s[0],s[-1])))(input())
52 symbols python3
Wed Jul 30 00:38:02 2014 vik
s=input()
q,d=s[0],s[len(s)-1]
print(s.replace(q,d))
55 symbols python2
Wed Jul 30 00:36:45 2014 vik
s=raw_input()
q,d=s[0],s[len(s)-1]
print s.replace(q,d)

View all solutions