"함수 StringReverse()"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
[[category: String]]
{{lowercase title}}
{{lowercase title}}
;reverse
;reverse
10번째 줄: 11번째 줄:


==Bash==
==Bash==
[[category: Bash]]
<source lang='bash'>
<source lang='bash'>
STR=`echo "hello" | rev`
STR=`echo "hello" | rev`
17번째 줄: 19번째 줄:


==C#==
==C#==
[[category: Csharp]]
<source lang='csharp'>
<source lang='csharp'>
public static string str_reverse(string str)
public static string str_reverse(string str)
27번째 줄: 30번째 줄:


==Excel==
==Excel==
[[category: Excel]]
*[[using VBA]]
*[[using VBA]]
<source lang='vb'>
<source lang='vb'>
39번째 줄: 43번째 줄:


==Java==
==Java==
[[category: Java]]
<source lang="java">
<source lang="java">
new StringBuilder("hello").reverse().toString()              // returns "olleh"
new StringBuilder("hello").reverse().toString()              // returns "olleh"
55번째 줄: 60번째 줄:


==Perl==
==Perl==
[[category: Perl]]
<source lang="perl">
<source lang="perl">
reverse "hello"              # returns "olleh"
reverse "hello"              # returns "olleh"
60번째 줄: 66번째 줄:


==PHP==
==PHP==
[[category: PHP]]
<source lang="php">
<source lang="php">
strrev("hello");            // returns "olleh"
strrev("hello");            // returns "olleh"
68번째 줄: 75번째 줄:


==Python==
==Python==
[[category: Python]]
<source lang="python">
<source lang="python">
"hello"[::-1]                # returns "olleh"
"hello"[::-1]                # returns "olleh"
73번째 줄: 81번째 줄:


==Ruby==
==Ruby==
[[category: Ruby]]
<source lang="ruby">
<source lang="ruby">
"hello".reverse                # returns "olleh"
"hello".reverse                # returns "olleh"
78번째 줄: 87번째 줄:


==Scheme==
==Scheme==
[[category: Scheme]]
<source lang="scheme">
<source lang="scheme">
(use-modules (srfi srfi-13))
(use-modules (srfi srfi-13))
84번째 줄: 94번째 줄:


==SQL==
==SQL==
[[category: SQL]]
===MySQL===
===MySQL===
[[category: MySQL]]
<source lang='sql'>
<source lang='sql'>
SELECT REVERSE( "hello world" );
SELECT REVERSE( "hello world" );
91번째 줄: 103번째 줄:


==VB==
==VB==
[[category: VB]]
<source lang='vb'>
<source lang='vb'>
str = StrReverse("hello")
str = StrReverse("hello")
</source>
</source>
[[category: String]]
[[category: Bash]]
[[category: Csharp]]
[[category: Excel]]
[[category: Java]]
[[category: Perl]]
[[category: PHP]]
[[category: Python]]
[[category: Ruby]]
[[category: Scheme]]
[[category: SQL]]
[[category: MySQL]]
[[category: VB]]

2013년 12월 15일 (일) 17:41 판

reverse
str_reverse
StrReverse
strrev

1 Overview

  • Definition: reverse(string)
  • Description: Reverses the order of the characters in the string.

2 Bash

STR=`echo "hello" | rev`
echo $STR
# olleh

3 C#

public static string str_reverse(string str)
{
  char[] arr = str.ToCharArray();
  Array.Reverse(arr);
  return new string(arr);
}

4 Excel

Option Explicit
Public Function str_reverse(str As String)
    str_reverse = StrReverse(str)
End Function
=str_reverse("hello")

5 Java

new StringBuilder("hello").reverse().toString()              // returns "olleh"

6 JavaScript

String.prototype.reverse=function(){return this.split("").reverse().join("");}
function reverse(s){
    return s.split("").reverse().join("");
}

7 Perl

reverse "hello"              # returns "olleh"

8 PHP

strrev("hello");             // returns "olleh"
echo strrev("hello"); // olleh

9 Python

"hello"[::-1]                # returns "olleh"

10 Ruby

"hello".reverse                # returns "olleh"

11 Scheme

(use-modules (srfi srfi-13))
(string-reverse "hello")     ; returns "olleh"

12 SQL

12.1 MySQL

SELECT REVERSE( "hello world" );
-- dlrow olleh

13 VB

str = StrReverse("hello")