Identifying substrings based on complex rules

前端 未结 3 799
野趣味
野趣味 2021-01-20 02:13

Assume I have text strings that look something like this:

A-B-C-I1-I2-D-E-F-I1-I3-D-D-D-D-I1-I1-I2-I1-I1-I3-I3

Here I want to identify sequ

3条回答
  •  梦毁少年i
    2021-01-20 02:27

    You can identify the sequences which contains I3 with following regex :

    (?:I\\d-?)*I3(?:-?I\\d)*
    

    So you can split your text with this regex to get the desire result.

    See demo https://regex101.com/r/bJ3iA3/4

提交回复
热议问题