함수 substr_count()


1 개요[ | ]

함수 substr_count()

2 Java[ | ]

Java
Copy
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
    }
}
Loading

3 PHP[ | ]

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

4 Python[ | ]

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

5 같이 보기[ | ]