python正则表达式获取两段标记内的字符串
2017-03-24 14:37
274 查看
比如获取绿色字符串
只需要
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.PayTableData\s*=\s*(\[.+?\])', rawStr, re.S) if m: print m.group(1) else: print 'no match' fp.close()
相关文章推荐
- Python通过正则表达式和字符串处理获取方式获取所需子字符串的方式
- python读配置文件;正则表达式替换、切割字符串;获取当前时间
- iPhone开发--正则表达式获取字符串中的内容
- android正则表达式获取字符串ip及端口复习
- python+正则表达式获取ed2k url
- 使用正则表达式 exec 获取字符串中的汉字
- Python 正则表达式匹配字符串中的http链接
- iPhone开发--正则表达式获取字符串中的内容
- 正则表达式获取两个标记之间的所有html
- php正则表达式 获取开始字符串和结束字符串中的部分内容
- Python 3(4)数据类型:字符串 & 正则表达式
- python字符串与正则表达式
- python+正则表达式获取ed2k url
- 运行一个命令或程序获取结果/正则表达式查找匹配/分隔字符串
- C#中利用正则表达式获取字符串中双引号包含的内容
- python正则表达式判断字符串是否是全部小写示例
- Python 正则表达式 字符串的匹配、替换、分割、查找
- python字符串及正则表达式[转]
- Python 第十四周 字符串与正则表达式
- Python开发技术详解-笔记_第06章-字符串与正则表达式