1
A
回答
1
我不知道爲什麼你需要爲這個正則表達式,因爲你可以「選擇」你想要的字符串簡單地做:
String myStr = "father";
另外,如果您需要更換的子字符串中,你可以做到以下幾點:
String myStr = "father goes visit his grandfather and and his father today."
myStr = myStr.Replace(" father ", " someOtherString ");
但是,如果你真的想使用正則表達式,你可以通過執行獲得MatchCollection
:
String myStr = "father goes visit his grandfather and and his father today."
Regex.Mathces(myStr, "\bfather\b");
這不是一個非常有趣的正則表達式,因爲它只是一個明確的字符串文字。
1
試試這個
var matchs=Regex.matches("father goes visit his grandfather and and his father today.",@"\bfather\b");
1
var matchCollection = Regex.Matches("father goes visit his grandfather and and his father today.", "\bfather\b");
foreach (Match m in matchCollection)
{
// Process your code for each match
}
相關問題
- 1. 如何創建這個lambda表達式?
- 2. 如何創建這個雙重條件?
- 3. 如何用條件創建這個宏?
- 4. 如何爲這個模式創建正則表達式/ posts /:post_id?
- 5. 這個三元條件表達式是如何執行的?
- 6. 如何爲這個表達式寫一個正則表達式?
- 7. 如何形成這個表達式
- 8. 如何刪除這個表達式?
- 9. 如何使這個表達式否定
- 10. 如何做這個正則表達式?
- 11. 我如何使用這個表達式
- 12. 如何寫這個正則表達式?
- 13. 如何寫這個正則表達式
- 14. 如何改善這個xpath表達式?
- 15. 如何擴展這個表達式?
- 16. Python如何評估這個表達式?
- 17. 如何簡化這個表達式?
- 18. 如何寫這個正則表達式
- 19. 如何簡化這個Xpath表達式?
- 20. LINQ表達式和這個
- 21. 我如何把這些AngularJS表達式到這個特定表
- 22. 如何創建一個正則表達式來解析這個字符串
- 23. 如何創建這個CSS?
- 24. 如何創建這個關係表?
- 25. 如何創建這個Kakuro表?
- 26. 如何創建這個bat文件?
- 27. 這個linq表達式創建有什麼問題(使用contains)
- 28. 是這個postgres正則表達式相當於這個表達式嗎?
- 29. 正則表達式,該表達式或如何拆分這個表達式
- 30. Excel條件格式 - 如果這個複製這個單元格