我想从indexof("&")直到下一行的subString,我的代码是
String substring = thisSrch.srchdesc.substring(thisSrch.srchdesc.indexOf("&"), frstNextNewLine);但我不知道我怎么能找到frstNextNewLine为frstNextNewLine我想检测“ &Ali是加入的第一个人。 ”在下面的文字
一个美妙的宁静占据了我的整个灵魂,就像我春天的甜蜜的早晨,我全心全意地享受。
&Ali是第一个加入的人。
我独自一人,在这个地方感受到存在的魅力,这是为了像我一样的灵魂所创造的。
i want subString from indexof("&") until next line,my code is
String substring = thisSrch.srchdesc.substring(thisSrch.srchdesc.indexOf("&"), frstNextNewLine);but i dont know how i can find frstNextNewLine for exmaple i want detect "& Ali is First person that joined." in below text
A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.
& Ali is First person that joined.
I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine.
最满意答案
int andIndex = thisSrch.srchdesc.indexOf("&"); String substring = thisSrch.srchdesc.substring(andIndex, thisSrch.srchdesc.indexOf("\n", andIndex));上面使用的indexOf函数接受一个参数,以开始在'&'字符的索引之后查找新行。
int andIndex = thisSrch.srchdesc.indexOf("&"); String substring = thisSrch.srchdesc.substring(andIndex, thisSrch.srchdesc.indexOf("\n", andIndex));The indexOf function used above accepts a parameter to starting looking for new line after the index of the '&' character.
更多推荐
发布评论