Difference between regex quantifiers plus and star

前端 未结 5 1802
轮回少年
轮回少年 2020-11-27 08:37

I try to extract the error number from strings like \"Wrong parameters - Error 1356\":

 Pattern p = Pattern.compile(\"(\\\\d*)\");
 Matcher m =          


        
5条回答
  •  盖世英雄少女心
    2020-11-27 09:06

    With the pattern /d+ at least one digit will need to be reached, and then the match will return all subsequent characters until a non-digit character is reached.

    /d* will match all the empty strings (zero or more), as well at the match. The .Net Regex parser will return all these empty string groups in its set of matches.

提交回复
热议问题