1 Bash[ | ]
Bash
Copy
str='hello world'
echo ${str#*ll}
# o world
echo ${str#*l}
# lo world
echo ${str#*x}
# hello world
2 Go[ | ]

Go
CPU
-1.0s
MEM
-0M
-1.0s
Copy
package main
import (
"fmt"
"strings"
)
func substrAfter(haystack string, needle string) string {
pos := strings.Index(haystack, needle)
if pos == -1 {
return ""
}
return haystack[pos+len(needle):]
}
func main() {
fmt.Println(substrAfter("hello world", "l")) // lo world
fmt.Println(substrAfter("hello world", "ll")) // o world
fmt.Println(substrAfter("hello world", "x")) //
}
lo world o world
3 PHP[ | ]

PHP
Copy
function substr_after($needle, $haystack) { return substr( strchr($haystack,$needle), strlen($needle) ); }
echo substr_after('ll', 'hello world');
echo substr_after('l', 'hello world');
echo substr_after('x', 'hello world'); // bool(false)
# o world
# lo world
#
4 같이 보기[ | ]
로그인하시면 댓글을 쓸 수 있습니다.
PHP 파일 다운로드 구현 2 (한글 파일명 지원) ― …PHP에서 오라클 DB 사용 ― YoWuPHP 파일 업로드 구현 ― 일리단사오육칠PHP 파일 업로드 구현 ― JmnotePHP 파일 다운로드 구현 2 (한글 파일명 지원) ― AnmkstLib my.php ― 신정섭Lib my.php ― Jmnote로또번호 생성 ―Pinkcrimson