fork(1) download
  1. function mirror(s) {
  2. return s.replace(/([LRFBUD])([2']?)/g, function(m, s, a){
  3. return ((s=='L')?'R':(s=='R')?'L':s) + ((a=='')?"'":(a=='2')?a:'');
  4. });
  5. }
  6. print(mirror("L R' F2 B U2 D'"));
  7.  
Success #stdin #stdout 0.01s 4984KB
stdin
Standard input is empty
stdout
R' L F2 B' U2 D