标题: 正则大佬们,这段正则应该怎么匹配才能得到目标
时间: 2021-04-29
今天没事看了下正则,随便抓了一段数据,想联系用正则提取
"scoreFlag": 1,
"scoreWeight": 1,
"score": 1.3,
"limitTime": 2000,
"testsNum": 100,
"gateContitionValue": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"testsType": 1,
"passContitionRequest": 2,
"passContitionValue": "90",
"state": 0,
"gateRepeat": 0,
"gateRepeatMarkWeight": 0.2,
"passFailureMarkWeight": 0.2,
"gateSuperId": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"mark": "",
"answerWrongFlag": 0,
"courseInfoIds": "",
"rushState": 2,
"crtUser": "admin001",
"crtTime": "2020-07-26 10:10:02",
"crtIp": "192.168.13.48",
"updTime": "2020-07-26 10:10:01",
"id": "e562edd3-49d6-459f-ab43-62e06551509b"
}
{
"scoreFlag": 1,
"scoreWeight": 1,
"score": 1.3,
"limitTime": 2000,
"testsNum": 100,
"gateContitionValue": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"testsType": 1,
"passContitionRequest": 2,
"passContitionValue": "90",
"state": 0,
"gateRepeat": 0,
"gateRepeatMarkWeight": 0.2,
"passFailureMarkWeight": 0.2,
"gateSuperId": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"mark": "",
"answerWrongFlag": 0,
"courseInfoIds": "",
"rushState": 2,
"crtUser": "admin001",
"crtTime": "2020-07-26 10:10:02",
"crtIp": "192.168.13.48",
"updTime": "2020-07-26 10:10:01",
"id": "e562edd3-49d6-459f-ab43-62e06551509b"
}
{
"scoreFlag": 1,
"scoreWeight": 1,
"score": 1.3,
"limitTime": 2000,
"testsNum": 100,
"gateContitionValue": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"testsType": 1,
"passContitionRequest": 2,
"passContitionValue": "90",
"state": 0,
"gateRepeat": 0,
"gateRepeatMarkWeight": 0.2,
"passFailureMarkWeight": 0.2,
"gateSuperId": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"mark": "",
"answerWrongFlag": 0,
"courseInfoIds": "",
"rushState": 2,
"crtUser": "admin001",
"crtTime": "2020-07-26 10:10:02",
"crtIp": "192.168.13.48",
"updTime": "2020-07-26 10:10:01",
"id": "e562edd3-49d6-459f-ab43-62e06551509b"
}
目标是提取到id:后面双引号里面的内容。
我用一下只能匹配到id一行的内容。不能一次得到里面的内容。
"id": "(.*)"
特来问问大佬们怎么提的
小米8(白)
『回复列表(8|隐藏机器人聊天)』
<?php
date_default_timezone_set('Asia/Shanghai');
$str = '
"scoreFlag": 1,
"scoreWeight": 1,
"score": 1.3,
"limitTime": 2000,
"testsNum": 100,
"gateContitionValue": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"testsType": 1,
"passContitionRequest": 2,
"passContitionValue": "90",
"state": 0,
"gateRepeat": 0,
"gateRepeatMarkWeight": 0.2,
"passFailureMarkWeight": 0.2,
"gateSuperId": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"mark": "",
"answerWrongFlag": 0,
"courseInfoIds": "",
"rushState": 2,
"crtUser": "admin001",
"crtTime": "2020-07-26 10:10:02",
"crtIp": "192.168.13.48",
"updTime": "2020-07-26 10:10:01",
"id": "e562edd3-49d6-459f-ab43-62e06551509b"
}
{
"scoreFlag": 1,
"scoreWeight": 1,
"score": 1.3,
"limitTime": 2000,
"testsNum": 100,
"gateContitionValue": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"testsType": 1,
"passContitionRequest": 2,
"passContitionValue": "90",
"state": 0,
"gateRepeat": 0,
"gateRepeatMarkWeight": 0.2,
"passFailureMarkWeight": 0.2,
"gateSuperId": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"mark": "",
"answerWrongFlag": 0,
"courseInfoIds": "",
"rushState": 2,
"crtUser": "admin001",
"crtTime": "2020-07-26 10:10:02",
"crtIp": "192.168.13.48",
"updTime": "2020-07-26 10:10:01",
"id": "e562edd3-49d6-459f-ab43-62e06551509b"
}
{
"scoreFlag": 1,
"scoreWeight": 1,
"score": 1.3,
"limitTime": 2000,
"testsNum": 100,
"gateContitionValue": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"testsType": 1,
"passContitionRequest": 2,
"passContitionValue": "90",
"state": 0,
"gateRepeat": 0,
"gateRepeatMarkWeight": 0.2,
"passFailureMarkWeight": 0.2,
"gateSuperId": "d15a105a-ccbd-462c-aa61-f9c8858a6224",
"mark": "",
"answerWrongFlag": 0,
"courseInfoIds": "",
"rushState": 2,
"crtUser": "admin001",
"crtTime": "2020-07-26 10:10:02",
"crtIp": "192.168.13.48",
"updTime": "2020-07-26 10:10:01",
"id": "e562edd3-49d6-459f-ab43-62e06551509b"
}
';
preg_match_all('/"id":."(.*)?"/',$str,$arr);
var_dump($arr);
array(2) {
[0]=>
array(3) {
[0]=>
string(44) ""id": "e562edd3-49d6-459f-ab43-62e06551509b""
[1]=>
string(44) ""id": "e562edd3-49d6-459f-ab43-62e06551509b""
[2]=>
string(44) ""id": "e562edd3-49d6-459f-ab43-62e06551509b""
}
[1]=>
array(3) {
[0]=>
string(36) "e562edd3-49d6-459f-ab43-62e06551509b"
[1]=>
string(36) "e562edd3-49d6-459f-ab43-62e06551509b"
[2]=>
string(36) "e562edd3-49d6-459f-ab43-62e06551509b"
}
}