zoukankan      html  css  js  c++  java
  • python正则表达式获取两段标记内的字符串

    比如获取绿色字符串

    ModelData.PayTableData =[{"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_5.png","ResVar":null,"X":"175","Y":"170","Scale":"0.7","Zorder":"4"},
        {"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_4.png","ResVar":null,"X":"325","Y":"170","Scale":"0.7","Zorder":"3"},
        {"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_3.png","ResVar":null,"X":"475","Y":"170","Scale":"0.7","Zorder":"2"}];
    ModelData.PayTableData1 =[{"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_5.png","ResVar":null,"X":"175","Y":"170","Scale":"0.7","Zorder":"4"},
        {"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_4.png","ResVar":null,"X":"325","Y":"170","Scale":"0.7","Zorder":"3"},
        {"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_3.png","ResVar":null,"X":"475","Y":"170","Scale":"0.7","Zorder":"2"}];
    
    
    ModelData.PayTableData2 =[{"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_5.png","ResVar":null,"X":"175","Y":"170","Scale":"0.7","Zorder":"4"},
        {"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_4.png","ResVar":null,"X":"325","Y":"170","Scale":"0.7","Zorder":"3"},
        {"SlotID":"1","GroupID":"1","GroupH":"250","GroupType":"0","CellID":"0","CellH":"0","Row":"1","ResType":"1","Res":"Slot1&slot1_wild_3.png","ResVar":null,"X":"475","Y":"170","Scale":"0.7","Zorder":"2"}];

    只需要

    #editor:pengyingh 17 3 24
    #encoding:utf-8
    #!/usr/bin/python
    import os
    import sys
    import json
    import string
    import re
    jsPath = sys.argv[1]
    #appendPath = jsPath[:jsPath.rindex('/') + 1]
    fp = open(jsPath, 'r')
    rawStr = fp.read()
    #print(rawStr[613:])
    m = re.search(r'ModelData.PayTableDatas*=s*([.+?])', rawStr, re.S)
    if m:
        print m.group(1)
    else:
        print 'no match'
    fp.close()
  • 相关阅读:
    Spring优势
    Spring中的设计模式
    Spring MVC体系结构
    《Spring3.0就这么简单》第1章快速入门
    InvocationHandler
    JdkDynamicAopProxy源码
    Proxy代理(AOP实现原理)
    Spring AOP 实现原理
    BeanFactory和ApplicationContext的作用和区别
    背景图片相关设置
  • 原文地址:https://www.cnblogs.com/pengyingh/p/6611424.html
Copyright © 2011-2022 走看看