1 개요[ | ]
- startsWith()
- startswith()
- HasPrefix()
- str_starts_with()
2 Go[ | ]

Go
Copy
package main
import (
"fmt"
"strings"
)
func main() {
str := "Hello world!"
// true
fmt.Println(strings.HasPrefix(str, "Hello"))
fmt.Println(strings.HasPrefix(str, "He"))
fmt.Println(strings.HasPrefix(str[2:], "ll"))
// false
fmt.Println(strings.HasPrefix(str, "ll"))
}
Loading
3 JavaScript[ | ]

JavaScript
Copy
const str = "Hello world!";
console.log( str.startsWith("Hello") ); // true
console.log( str.startsWith("He") ); // true
console.log( str.startsWith("ll", 2) ); // true
console.log( str.startsWith("ll") ); // false
▶ | true |
▶ | true |
▶ | true |
▶ | false |
4 PHP[ | ]

PHP
Copy
<?php
$str = 'To be, or not to be, that is the question.';
var_dump(str_starts_with($str, 'To be'));
var_dump(str_starts_with($str, 'not to be'));
Loading
5 Python[ | ]

Python
Copy
str = 'Hello world!'
# True
print( str.startswith( 'Hello' ) )
print( str.startswith( 'He' ) )
print( str.startswith( 'll', 2 ) )
print( str.startswith( 'Hell', 0, 4 ) )
# False
print( str.startswith( 'll' ) )
print( str.startswith( 'Hell', 0, 3 ) )
Loading
6 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.