[英]regex - single char plural finding java
串
The method according to claims 1 to 6
The method of claim 1,
我的正則表達式
\\bclaim\\s+(\\d+)
it finding the digits after the word claim
如果單詞claim
自己找到了數字,如果單詞claims
自己沒有找到數字
所以我改變了我的正則表達式
\\bclaim(?=s)\\s+(\\d+)
但沒有找到主張。讓我知道其他可能性
嘿,只需使用以下正則表達式,
String pattern = "\\bclaims?\\s+(\\d+)";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str);
if (m.find( ))
System.out.println(m.group());
輸出:
claims 1
claim 1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.