함수 contains()

  다른 뜻에 대해서는 import 문서를 참조하십시오.

1 개요[ | ]

contains
.include

2 ALGOL 68[ | ]

 string in string("e", loc int, "Hello mate");      ¢ returns true ¢
 string in string("z", loc int, "word");            ¢ returns false ¢

3 C#[ | ]

"Hello mate".Contains("e");      // returns true
"word".Contains("z");            // returns false

4 Excel[ | ]

=ISNUMBER(SEARCH("hello", "hello world"))
// TRUE
=ISNUMBER(SEARCH("olleh", "hello world"))
// FALSE
=NOT(ISERR(FIND("hello","hello world")))
// TRUE
=NOT(ISERR(FIND("olleh","hello world")))
// FALSE
=ISERR(FIND("hello","hello world"))
// FALSE
=ISERR(FIND("olleh","hello world"))
// TRUE

5 Go[ | ]

package main

import "fmt"
import "strings"

func main() {
	// true
	fmt.Println(strings.Contains("Hello mate", "e"))
	fmt.Println(strings.Contains("Hello mate", "llo"))

	// false
	fmt.Println(strings.Contains("word", "z"))
	fmt.Println(strings.Contains("word", "war"))
}

6 Java[ | ]

Java 1.5+
"Hello mate".contains("e");      // returns true
"word".contains("z");            // returns false

7 JavaScript[ | ]

console.log( "Hello mate".indexOf("e") > -1 );      // true
console.log( "word".indexOf("z") > -1 ); // false

8 PHP[ | ]

function contains($str, $text) { return (strpos($text, $str) !== false); }

var_dump( contains("ll", "Hello mate"));  # bool(true)
var_dump( contains("ate", "Hello mate")); # bool(true)

var_dump( contains("z", "Hello mate"));     # bool(false)
var_dump( contains("hello", "Hello mate")); # bool(false)

9 Python[ | ]

print( "ll" in "Hello mate" )  # True
print( "ate" in "Hello mate" ) # True

print( "z" in "Hello mate" )     # False
print( "hello" in "Hello mate" ) # False

10 Perl[ | ]

( "Hello mate" =~ /e/ ); # returns true
( "Hello mate" =~ /Z/ ); # returns false

11 R[ | ]

grepl("ll", "Hello mate")  ## [1] TRUE
grepl("ate", "Hello mate") ## [1] TRUE

grepl("z", "Hello mate")     ## [1] FALSE
grepl("hello", "Hello mate") ## [1] FALSE

12 Ruby[ | ]

puts "Hello mate".include?("e")
# true
puts "word".include?("z")
# false
puts "Hello mate".include?("ll") 
# true

13 같이 보기[ | ]

14 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}