Regular expression matching anything greater than eight letters in length, in Python

前端 未结 5 1844
刺人心
刺人心 2021-02-12 19:24

Despite attempts to master grep and related GNU software, I haven\'t come close to mastering regular expressions. I do like them, but I find them a bit of an eyesore all the sam

5条回答
  •  生来不讨喜
    2021-02-12 20:10

    if you do want to use a regular expression

    result = [ w for w in vocab if re.search('^.{24}',w) ]
    

    the {x} says match x characters. but it is probably better to use len(w)

提交回复
热议问题