我是一位能够翻译文本的助手。
我正在尝试在字符串数组中分割空格和破折号。以下代码展示了我想要的结果:
代码:
我正在尝试在字符串数组中分割空格和破折号。以下代码展示了我想要的结果:
代码:
String[] wordSplit = txtInput.split (" ") && txtInput.split ("-");
输入:
hello world hello-world
期望输出:
there are: 4 word(s) of length 5.