Java 相当于 PHP str_word_count?

标签 java php word-count

注意:我不是在寻找 Java 中的字数统计算法。我问哪里可以找到str_word_count在 PHP 源代码中。

我希望重新创建(逐字记录,如果可能的话逐行) str_word_count PHP 函数作为 Java 方法:

public class PhpWordCounter {
    public int strWordCount(String str) {
        // The exact algorithm used in PHP's str_word_count here...
        // The str_word_count method takes an optional parameter
        // "format", which, if 0, returns the number of words.
        // This is the portion of the routine that I will actually
        // be mimicking.
    }
}

我刚刚下载了 PHP 5.3.23 的源代码(tarball)并解压。我搜索str_word_count并没有找到任何东西,所以我什至不知道要寻找什么,更不用说要搜索什么文件了。有人有什么想法吗?提前致谢!

最佳答案

好吧,你应该看起来更好:)它应该在最新的稳定分支 http://www.php.net/manual/en/function.str-word-count.php 中可用。

find . -type f -exec grep -l 'str_word_count' {} \;

./ext/standard/php_string.h
./ext/standard/tests/strings/str_word_count1.phpt
./ext/standard/tests/strings/str_word_count.phpt
./ext/standard/basic_functions.c
./ext/standard/string.c

关于Java 相当于 PHP str_word_count?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15497121/

相关文章:

php - 插入查询到MYSQL数据库

javascript - Stripe 通话已记录,但未产生任何测试费用

java - 在 Hadoop-2.6.0 中运行我自己的 WordCount.java 版本

计算每个单词在给定句子中出现的次数

java - Jenkins 文件路径作为参数

java - 使用 Jaxb unmarshal/marshal 时线程 "main"java.lang.NullPointerException 中出现异常

java - 使用 yacc 文件检测 Java 文本区域中的语法错误

java - 当 lambda 可能返回 null 时,如何使 IntelliJ IDEA 发出警告?

php - 有没有办法让 cURL 等到页面的动态更新完成?

java - Hadoop - 每个节点的字数