repeating a section of a regular expression?

前端 未结 2 707
死守一世寂寞
死守一世寂寞 2020-12-20 11:26

I\'m having to parse a text dump of a spreadsheet. I have a regular expression that correctly parses each line of the data, but it\'s rather long. It\'s basically just mat

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 12:08

    (\s+(\w*\.*\w*);){12}

    The {n} is a "repeat n times"

    if you want "12 - 13" times,

    (\s+(\w*\.*\w*);){12,13}

    if you want "12+" times,

    (\s+(\w*\.*\w*);){12,}

提交回复
热议问题