从特定单词后面的字符串中获取子字符串 [英] Getting a substring from a string after a particular word
本文介绍了从特定单词后面的字符串中获取子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下字符串。
ABC Results for draw no 2888
我想从这里提取 2888
。这意味着,我需要在上面的字符串中 no
之后提取字符。
I would like to extract 2888
from here. That means, I need to extract characters after no
in above string.
我总是提取后的数字单词否
。字符串中不包含其他否
字母组合。字符串可能包含其他数字,我不需要提取它们。总是在数字之前会有一个空格,我希望提取的数字总是在字符串的末尾。
I'm always extract the number after the word no
. The String contain no other no
letter combinations elsewhere within it. String may contain other numbers and I don't need to extract them. Always there will be a space before the number and the number I wish to extract always be at the end of the String.
我怎样才能实现这个目标?
How could I achieve this ?
推荐答案
yourString.substring(yourString.indexOf("no") + 3 , yourString.length());
这篇关于从特定单词后面的字符串中获取子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文