Clean Python Regular Expressions

前端 未结 3 2098
渐次进展
渐次进展 2020-12-10 11:51

Is there a cleaner way to write long regex patterns in python? I saw this approach somewhere but regex in python doesn\'t allow lists.

patterns = [
    re.co         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 12:35

    Though @Ayman's suggestion about re.VERBOSE is a better idea, if all you want is what you're showing, just do:

    patterns = re.compile(
            r'
         
     
    热议问题