【问题标题】:Intellij Search Regex, select specific capture groupIntellij Search Regex,选择特定的捕获组
【发布时间】:2021-11-15 05:04:59
【问题描述】:

我目前正在用 intellij 玩正则表达式,我想知道是否可以使用捕获来选择特定组的所有出现。

12 330
13 450
1223 870
1213 900

regex: (^\d+) (\d+) 

and select the 
330 
450 
870 
900 

which are in the group 2

谢谢 ;)

【问题讨论】:

    标签: regex intellij-idea capturing-group


    【解决方案1】:

    您不需要组。使用

    ^\d+ \K\d+
    

    regex proof

    解释

    --------------------------------------------------------------------------------
      ^                        the beginning of the string
    --------------------------------------------------------------------------------
      \d+                      digits (0-9) (1 or more times (matching
                               the most amount possible))
    --------------------------------------------------------------------------------
                               ' '
    --------------------------------------------------------------------------------
      \K                       match reset operator
    --------------------------------------------------------------------------------
      \d+                      digits (0-9) (1 or more times (matching
                               the most amount possible))
    

    【讨论】:

    • 哈哈我知道这个例子可以用另一个正则表达式来实现,目的只是想知道intellij是否可以处理捕获组选择。
    猜你喜欢
    • 1970-01-01
    • 2013-03-06
    • 1970-01-01
    • 2010-10-04
    • 1970-01-01
    • 2017-08-16
    • 2013-12-04
    • 1970-01-01
    相关资源
    最近更新 更多