I have a very complicated output from a function, which i need to use specific word from it.
For example , my output is:
oracle 11257 1 0 14:01 ? 00:00:00 ora_pmon_sas
I need to get just " sas
" word, which is next to " ora_pmon_
"
Another example:
oracle 6187 1 0 13:41 ? 00:00:00 ora_pmon_db2
I need to get " db2
". So what should be my expression?
JAVA code:
insArray=line.split("what will be between these quotes?");
你可以做
String sub = s.substring(s.indexOf("ora_pmon_") + 9);
How about this one?
string = string.replaceAll(".*?ora_pmon_", "");
If you want multiple words in place of ora , then it will be
string = string.replaceAll(".*?(ora|kf|asm)_pmon_", "");
You can simply use String#substring(int i) combined with String#lastIndexOf(char ch)
For example:
String result = input.substring(input.lastIndexOf('_') + 1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.