Python re infinite execution

前端 未结 4 2139
日久生厌
日久生厌 2020-12-05 18:40

I\'m trying to execute this code :

import re
pattern = r\"(\\w+)\\*([\\w\\s]+)*/$\"
re_compiled = re.compile(pattern)
results = re_compiled.search(\'COPRO*H         


        
4条回答
  •  有刺的猬
    2020-12-05 19:36

    Interestingly, Perl runs it very quickly

    -> perl -e 'print "Match\n" if "COPRO*HORIZON 2000                 HOR" =~ m|(\w+)\*([\w\s]+)*/$|'
    -> perl -e 'print "Match\n" if "COPRO*HORIZON 2000                 HOR/" =~ m|(\w+)\*([\w\s]+)*/$|'
    Match
    

提交回复
热议问题