javascript - Correspond régulièrement à plusieurs valeurs et renvoie le groupe spécifié
滿天的星座
滿天的星座 2017-05-17 10:08:30
0
3
723
[
  {
    "thumbURL": "http://img0.imgtn.bdimg.com/it/u=3025588030,3916696758&fm=23&gp=0.jpg",
    "adType": "0",
    "middleURL": "http://img0.imgtn.bdimg.com/it/u=3025588030,3916696758&fm=23&gp=0.jpg",
    "largeTnImageUrl": "",
    "hasLarge": 0,
    "hoverURL": "http://img0.imgtn.bdimg.com/it/u=3025588030,3916696758&fm=23&gp=0.jpg",
    "pageNum": 0,
    "objURL": "http://pic.58pic.com/58pic/13/89/42/50B58PICbPR_1024.jpg",
    "fromURL": "ippr_z2C$qAzdH3FAzdH3Fooo_z&e3Bcbrtv_z&e3Bv54AzdH3Frf1AzdH3F8nbl9dca_z&e3Bip4s",
    "fromURLHost": "www.58pic.com",
    "currentIndex": "",
    "width": 1024,
    "height": 625,
    "type": "jpg",
    "filesize": "",
    "bdSrcType": "0",
    "di": "166108309290",
    "is": "0,0",
    "bdSetImgNum": 0,
    "spn": 0,
    "bdImgnewsDate": "1970-01-01 08:00",
    "fromPageTitle": "<strong>广州<\/strong>夜景图片",
    "bdSourceName": "",
    "bdFromPageTitlePrefix": "",
    "isAspDianjing": 0,
    "token": "",
    "imgType": "",
    "adid": "0",
    "pi": "0",
    "cs": "3025588030,3916696758",
    "os": "442898692,2704726703",
    "simid": "4271495673,765344659",
    "source_type": "",
    "personalized": "0",
    "base64": '',
    "adPicId": "0"
  },
  {
    "thumbURL": "http://img3.imgtn.bdimg.com/it/u=986014556,2144085313&fm=23&gp=0.jpg",
    "adType": "0",
    "middleURL": "http://img3.imgtn.bdimg.com/it/u=986014556,2144085313&fm=23&gp=0.jpg",
    "largeTnImageUrl": "",
    "hasLarge": 0,
    "hoverURL": "http://img3.imgtn.bdimg.com/it/u=986014556,2144085313&fm=23&gp=0.jpg",
    "pageNum": 1,
    "objURL": "http://img.pconline.com.cn/images/upload/upc/tx/itbbs/1010/27/c2/5665647_1288194725363_1024x1024it.jpg",
    "fromURL": "ippr_z2C$qAzdH3FAzdH3Ftpkkf_z&e3Brv5gstgj_z&e3Bv54_z&e3BvgAzdH3F1vAzdH3F8da9988b_z&e3Bip4s",
    "fromURLHost": "itbbs.pconline.com.cn",
    "currentIndex": "",
    "width": 850,
    "height": 609,
    "type": "jpg",
    "filesize": "",
    "bdSrcType": "0",
    "di": "181589344090",
    "is": "0,0",
    "bdSetImgNum": 0,
    "spn": 0,
    "bdImgnewsDate": "1970-01-01 08:00",
    "fromPageTitle": "新鲜出炉《<strong>广州<\/strong>花城广场》+ 广州 塔",
    "bdSourceName": "",
    "bdFromPageTitlePrefix": "",
    "isAspDianjing": 0,
    "token": "",
    "imgType": "",
    "adid": "0",
    "pi": "0",
    "cs": "986014556,2144085313",
    "os": "1860476025,1446613078",
    "simid": "3378049948,192663593",
    "source_type": "",
    "personalized": "0",
    "base64": '',
    "adPicId": "0"
  },
  {
    "thumbURL": "http://img5.imgtn.bdimg.com/it/u=1201045279,2807563612&fm=23&gp=0.jpg",
    "adType": "0",
    "middleURL": "http://img5.imgtn.bdimg.com/it/u=1201045279,2807563612&fm=23&gp=0.jpg",
    "largeTnImageUrl": "",
    "hasLarge": 0,
    "hoverURL": "http://img5.imgtn.bdimg.com/it/u=1201045279,2807563612&fm=23&gp=0.jpg",
    "pageNum": 2,
    "objURL": "http://uploadfile.bizhizu.cn/2015/0314/20150314112515522.jpg",
    "fromURL": "ippr_z2C$qAzdH3FAzdH3F4_z&e3Bktzitz7_z&e3BvgAzdH3FktzitAzdH3F9b0n_z&e3Bip4s",
    "fromURLHost": "m.bizhizu.cn",
    "currentIndex": "",
    "width": 1920,
    "height": 1200,
    "type": "jpg",
    "filesize": "",
    "bdSrcType": "0",
    "di": "99549879990",
    "is": "0,0",
    "bdSetImgNum": 0,
    "spn": 0,
    "bdImgnewsDate": "1970-01-01 08:00",
    "fromPageTitle": "<strong>广州<\/strong>夜景图2",
    "bdSourceName": "",
    "bdFromPageTitlePrefix": "",
    "isAspDianjing": 0,
    "token": "",
    "imgType": "",
    "adid": "0",
    "pi": "0",
    "cs": "1201045279,2807563612",
    "os": "1767325581,810579076",
    "simid": "4162119815,795645113",
    "source_type": "",
    "personalized": "0",
    "base64": '',
    "adPicId": "0"
  }]

Les données source sont dans le format ci-dessus. Je souhaite faire correspondre les données dans objURL et fromPageTitle.

.

L'expression régulière que j'ai écrite moi-même est comme ça

"objURL":"(.*?) "fromPageTitle":"(.*?)"

Mais le résultat de la correspondance objURL inclut d'autres caractères entre objURL et fromPageTitle, et fromPageTitle est la valeur attendue
Je ne peux donc faire qu'une correspondance secondaire
Excusez-moi, existe-t-il un moyen de faire correspondre le lien derrière objURL et fromPageTitle à la fois ?

滿天的星座
滿天的星座

répondre à tous(3)
伊谢尔伦

Avec des données json aussi régulières, pourquoi ne pas utiliser json pour les faire fonctionner ?

小葫芦
a = 字符串
for i in re.findall(r'("objURL.*?fromPageTitle".*?),', a, re.S):
    print i
    
PHPzhong

Connaissez-vous le concept de regroupement ? Après la mise en correspondance, vous pouvez retirer le contenu entre parenthèses. Celui correspondant en java est Matcher.group(n)

.
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal