我在 JavaScript 中有以下字符串,这是一个基本的 oData 批量请求:
--batchfull
Content-Type: multipart/mixed; boundary=batchitems
--batchitems
Content-Type: application/http
Content-Transfer-Encoding: binary
MERGE /WcfDataService1.svc/Orders(1) HTTP/1.1
Content-Type: application/json;type=entry
{"OID":"2340324","PID":"234234"}
--batchitems
Content-Type: application/http
Content-Transfer-Encoding: binary
POST /WcfDataService1.svc/Users HTTP/1.1
Content-Type: application/json;type=entry
{"PID":"234234","Name":"User1"}
--batchitems--
--batchfull--
组成批处理的每个项目如下:
--batchitems
Content-Type: application/http
Content-Transfer-Encoding: binary
POST /WcfDataService1.svc/Users HTTP/1.1
Content-Type: application/json;type=entry
{"PID":"234234","Name":"User1"}
// new line here too
我正在尝试编写一个正则表达式来提取每个批处理项目,但我无法让它工作。到目前为止我已经:
/--batchitems$.*?(?=--batchitems)/ig
但是,它不起作用。
1)我尝试构建它,所以一开始我有/--batchitems$/ig。没有美元,它起作用,有了它,它不起作用(没有任何匹配)。
有什么想法可以让它发挥作用吗?
最佳答案
关于javascript - 前瞻正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32014316/