如何從段落中提取單詞「0U47NN4XMD8V」「已更新產品0U47NN4XMD8V的更新,可能需要長達1小時才能反映這些更改。請在一段時間後從產品搜索頁面檢查」使用java代碼?正則表達式的如何提取單詞「0U47NN4XMD8V」?
-4
A
回答
1
//This is your sentence you want to extract the code from
String sentence = "Changes for update of product 0U47NN4XMD8V has been submitted,it may take up to 1 hour for these changes to be reflected";
//This is an array of strings, which is your sentence split by every space,
//hence (" "), it can be (",") or anything else you wanna split by.
//This array has a size of 22 since you can split your sentence into 22 parts for
//every space and it starts at 0 since its Java
String [] parts = sentence.split(" ");
//We want the 6th element so we assign a string our 6th element
//in our array - parts[5] since it is zero based
String extracted = parts[5];
//do stuff
0
String code = "0U47NN4XMD8V" // Or a get method where this comes from
String message = "Changes for update of Product 0U47NN4XMD8V has been submitted,it may take up to 1 hour for these changes to be reflected";
if(message.contains(code)){
//do something
}
相關問題
- 1. 如何從行中提取單詞
- 2. 如何從URL中提取單詞?
- 3. 如何提取R中單詞子集的詞頻?
- 4. 提取整個單詞
- 5. 使用Perl提取單詞
- 6. 提取單詞的同義詞
- 7. 提取特定單詞後的第一個單詞
- 8. 詞提取
- 9. 如何提取/刪除每個頁面的第一個單詞?
- 10. 如何在postgresql中的2個單詞之間提取文本?
- 11. 如何使用python從文本中提取單詞?
- 12. 如何在PHP中使用preg_split()提取單詞和短語?
- 13. 如何提取方括號內的單詞?
- 14. 如何提取字符串後面的第一個單詞?
- 15. 如何從文本文件中提取單詞
- 16. Ruby:如何從字符串中提取單詞
- 17. 如何提取句子的最後一個單詞
- 18. 我如何從字符串中提取單詞?
- 19. PHP - 我如何提取大寫單詞從字符串
- 20. 如何從域名字符串中提取單詞
- 21. 如何從一個拆分字符串中提取單詞
- 22. 如何提取第二個冒號後的單詞?
- 23. 如何在matlab中用條件提取文本中的單詞?
- 24. 如何從grep中提取單詞結果在shell中?
- 25. 如何提取括號後的第一個「單詞」
- 26. 如何從Linux Shell中的句子中提取單詞?
- 27. 如何使用python從文本中提取確切的單詞?
- 28. 如何在某個單詞之前提取數字?
- 29. 如何在unix中多行提取單詞?
- 30. 如何根據上下文從文本中提取單詞
捏,代碼衝刺。徹底混合並在腦中烘烤10-20年。 –
你有沒有試過的代碼?什麼都可以顯示你正在使用什麼樣的系統? –
句子和'單詞'每次都完全一樣嗎?如果是這樣,你可以使用'substring()'和'word'的索引。 –