함수 substr_count()

Jmnote (토론 | 기여)님의 2021년 4월 14일 (수) 18:54 판 (→‎PHP)


1 개요

함수 substr_count()

2 Java

import java.util.regex.Pattern;
public class MyClass {
    public static void main(String args[]) {
        String s = "This is a test";
        String sub = "is";
        int count = s.split(sub,-1).length-1;
        System.out.println( count ); // 2
    }
}

3 PHP

echo substr_count('This is a test', 'is'); # 2
echo substr_count("Hello world. The world is nice","world"); # 2

4 Python

s = "Hello world. The world is nice"
print( s.count("world") )
# 2

5 같이 보기

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