Regular (? =) (? :) --- (two supplements)

4.15 Supplement requires a group solution

Insert picture description here

Then achieve matching HD-1-1, HD-2-3, zz-2-3

首先实现
    HD-1-1的匹配
    (([a-zA-Z]+)(?:-(\d+))*)
    可以是实现匹配
    接下来实现HD-1-1,HD-2-3,zz-2-3 的全匹配
    主要是在原来的基础上加上( ((原来)+)(,(原来)*) )  //这里写+是保证了至少匹配一次吧
   (((([a-zA-Z]+)(?:-(\d+))+))(,((([a-zA-Z]+)(?:-(\d+))*)*))*)

The point! ! (((Original) +) (, (Original) *))
Done!

Published 27 original articles · praised 1 · visits 1673

Guess you like

Origin blog.csdn.net/qq_37959151/article/details/105547849