Java Regex Error - No group 1

前端 未结 1 880
广开言路
广开言路 2021-01-19 00:10

I ran this as a UnitTest in my project

public class RadioTest {

    private static Pattern tier;
    private static Pattern frequency;
    private static Pa         


        
相关标签:
1条回答
  • 2021-01-19 00:48
    Pattern.compile("Tier: \\d");
    

    does not define a group so this expression matches but you can't extract a group. You'll probably want to do it like:

    Pattern.compile("Tier: (\\d)");
    

    Also for your other expressions. You'll need to () enclose parts that you want to extract as group.

    0 讨论(0)
提交回复
热议问题