Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想解析这个字符串“hello>kok>peoplekok”我希望分隔符不仅仅是一个字符,而是一个字符串。假设 ">kok>" 所以结果将是 1 : hello 2: peoplekok
我已经研究了 split() 方法,但似乎分隔符只是字符。
谢谢你的帮助。
split 方法采用正则表达式:) 试试
"hello>kok>peoplekok".split(">kok>");
也看看这个链接
String testString = "hello>kok>peoplekok"; String result[] = testString.split("">kok>");
现在结果包含答案
result[0] = hello result[1] = peoplekok