Python重新使用正则表达式查找

时间:2015-07-16 13:21:04

标签: python regex string

我有一个存储在变量中的大字符串,我想使用正则表达式重新搜索来删除所有垃圾文本并仅显示具有

的文本
  

释放/ somefilehere

并且必须用逗号分隔,例如

  

释放/ somefilehere1,释放/ somefilehere2,释放/ somefilehere3

重新搜索不应返回重复路径,因此不应返回

  

释放/ somefilehere1,释放/ somefilehere1

我真的很害怕正规表达可以帮助我吗?

变量中存储的字符串是:

/testing","displayId":"release/testing","latestChangeset":"12d7917fe9c78efa898e7ef45cf21be2ac727a75","isDefault":false},{ "id":"refs/heads/release/xzczx","displayId":"release/xzczx","latestChangeset":"12d7917fe9c78efa898e7ef45cf21be2ac727a75", "isDefault":false},{"id":"refs/heads/release/a.aa.a.2","displayId":"release/a.aa.a.2","latestChangeset":"c1c2c7d7741e4779 11de72154ad2e178a1bf793c","isDefault":false},{"id":"refs/heads/dev","displayId":"dev","latestChangeset":"3d432713d1a22be5 9a17ebdebfa298d87232ca7d","isDefault":false},{"id":"refs/heads/release/1a1","displayId":"release/1a1","latestChangeset":" 3d432713d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{"id":"refs/heads/release/aaaa","displayId":"release/aaaa"," latestChangeset":"3d432713d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{"id":"refs/heads/release/another_release" ,"displayId":"release/another_release","latestChangeset":"3d432713d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{" id":"refs/heads/release/asdasdasd","displayId":"release/asdasdasd","latestChangeset":"3d432713d1a22be59a17ebdebfa298d8723 2ca7d","isDefault":false},{"id":"refs/heads/release/my_branch","displayId":"release/my_branch","latestChangeset":"3d43271 3d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{"id":"refs/heads/release/one_last_test","displayId":"release/one_l ast_test","latestChangeset":"3d432713d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{"id":"refs/heads/release/pleas e_work","displayId":"release/please_work","latestChangeset":"3d432713d1a22be59a17ebdebfa298d87232ca7d","isDefault":false} ,{"id":"refs/heads/release/qqqqq","displayId":"release/qqqqq","latestChangeset":"3d432713d1a22be59a17ebdebfa298d87232ca7d ","isDefault":false},{"id":"refs/heads/release/test_branch","displayId":"release/test_branch","latestChangeset":"3d432713 d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{"id":"refs/heads/release/wwwwwwwwwwwwwwooorrrrrrrr","displayId":"re lease/wwwwwwwwwwwwwwooorrrrrrrr","latestChangeset":"3d432713d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{"id":"r efs/heads/release/zzzasdasda","displayId":"release/zzzasdasda","latestChangeset":"3d432713d1a22be59a17ebdebfa298d87232ca7 d","isDefault":false},{"id":"refs/heads/release/zzzsersfawda","displayId":"release/zzzsersfawda","latestChangeset":"3d432 713d1a22be59a17ebdebfa298d87232ca7d","isDefault":false},{"id":"refs/heads/prog_D_2a_aa_21_T1aa_joshg","displayId":" prog_D_2a_aa_21_T1aa_joshg","latestChangeset":"c3d2cc2d793c7ea7e797c2444f2aa391cac94aba","isDefault":false},{"id":" refs/heads/prog_D_2a_a1_21_T5727_joshg","displayId":"prog_D_2a_a1_21_T5727_joshg","latestChangeset":"282aafea 7eca8439df8baea9a7e1fa429f531123","isDefault":false},{"id":"refs/heads/prog_B_2a_19_21_DIAMOND-5a7_edwardb","displayId": "prog_B_2a_19_21_DIAMOND-5a7_edwardb","latestChangeset":"cf78a3735cf758dd3af7d31c5574e247feabdbe9","isDefault":false},{" id":"refs/heads/prog_D_2a_a2_21_T5727_joshg","displayId":"prog_D_2a_a2_21_T5727_joshg","latestChangeset":"247 ada79c2db2f9deae42253598aa7dd51acaaa2","isDefault":false},{"id":"refs/heads/prog_D_2a_19_2a_T5727_joshg","displayId ":"prog_D_2a_19_2a_T5727_joshg","latestChangeset":"9f45a81f9e7db7ad5b777a119ba3a8f55d4bdfc1","isDefault":false},{"i d":"refs/heads/prog_D_2a_19_21_T5727_joshg","displayId":"prog_D_2a_19_21_T5727_joshg","latestChangeset":"8d79 fa11f7f2b93cf4957c778f1e7e1bc2824ed9","isDefault":false},{"id":"refs/heads/prog_D_2a_18_21_T5727_joshg","displayId" :"prog_D_2a_18_21_T5727_joshg","latestChangeset":"5a838d357f137e77cbace8ca4fd74e7bff5b4daa","isDefault":false},{"id ":"refs/heads/prog_D_2a_17_T5727_joshg","displayId":"prog_D_2a_17_T5727_joshg","latestChangeset":"17b3af495f4 efbd9feffd25d728ea7a4c3dd784a","isDefault":false}],"start":2,"nextPageStart":a5}

1 个答案:

答案 0 :(得分:0)

Range(CurrentValue_Loc).Select 'CurrentValue_Loc = H5 in this case
If (ActiveCell.Value < Range(LoLo_Loc).Value Or ActiveCell.Value > Range(HiHi_Loc).Value) Then
ActiveCell.Interior.ColorIndex = 3