我正在尝试使用正则表达式抓取下面显示的JSON数据中第一次出现InvoiceItemID
:
这是我目前拥有的正则表达式字符串:
\d{6}(?=","Location":"ARN:190801210003100)
当前的正则表达式字符串返回两个匹配项,但我只对第一次出现/匹配感兴趣。我明白我需要做的是让正则表达式非贪婪,这通常涉及使用类似这样的东西:(.*?)
但我不知道在哪里实现这个非贪婪的代码。任何帮助,将不胜感激。感谢。
如果出于测试目的需要,以下是一些原始数据:
{"ClientRef":"","Date":"2015-09-29 10:02:51 AM","InvoiceID":"451393","InvoiceItemID":"495340","Location":"ARN:193602013349538<br\/>16 LEIGHLAND DR , CITY OF MARKHAM, ON, L3R 7R4","ReportID":"268172,","Type":"ICI Commercial \/ Industrial Report"},{"ClientRef":"","Date":"2015-09-28 8:39:41 PM","InvoiceID":"451035","InvoiceItemID":"494939","Location":"ARN:190801210003100<br\/>2250 SHEPPARD AVE W, CITY OF TORONTO, ON, M9M 1L7","ReportID":"267810,","Type":"Basic Report"},{"ClientRef":"","Date":"2015-09-28 8:39:20 PM","InvoiceID":"451034","InvoiceItemID":"494938","Location":"ARN:190801210003100<br\/>2250 SHEPPARD AVE W, CITY OF TORONTO, ON, M9M 1L7","ReportID":"267809,","Type":"ICI Commercial \/ Industrial Report"},{"ClientRef":"","Date":"2015-09-28 2:59:03 PM","InvoiceID":"450515","InvoiceItemID":"494348","Location":"ARN:240201011110900<br\/>26-34 PLAINS RD E, BURLINGTON CITY, ON, L7T 2B9","ReportID":"267272,","Type":"ICI Commercial \/ Industrial Report"}