1
我有一個像下面在匹配模式之前獲得單個匹配嗎?
{"id":9,"announcementName":"Test","announcementText":"<p>TestAssertion</p>\n","effectiveStartDate":"03/01/2016","effectiveEndDate":"03/02/2016","updatedDate":"02/29/2016","status":"Active","moduleName":"Individual Portal"}
{"id":103,"announcementName":"d3mgcwtqhdu8003","announcementText":"<p>This announcement is a test announcement」,"effectiveStartDate":"03/01/2016","effectiveEndDate":"03/02/2016","updatedDate":"02/29/2016","status":"Active","moduleName":"Individual Portal"}
{"id":113,"announcementName":"asdfrtwju3f5gh7f21","announcementText":"<p>This announcement is a test announcement」,"effectiveStartDate":"03/02/2016","effectiveEndDate":"03/03/2016","updatedDate":"02/29/2016","status":"InActive","moduleName":"Individual Portal"}
我試圖讓announcementName d3mgcwtqhdu8003的ID(103)的值的響應。
我使用下面的正則表達式來獲取ID
"id":(.*?),"announcementName":"${announcementName}","announcementText":"
但它匹配一切從第一證件到announcementName。並返回
9,"announcementName":"Test","announcementText":"<p>TestAssertion</p>\n","effectiveStartDate":"03/01/2016","effectiveEndDate":"03/02/2016","updatedDate":"02/29/2016","status":"Active","moduleName":"Individual Portal"}
{"id":103,"announcementName":"d3mgcwtqhdu8003","announcementText":
但我想只從ID 只是所需announcementName之前匹配。
如何在RegEx中執行此操作。有人可以幫助我嗎?
ps:無法爲此構建正確的問題標題。 : -/ –
你可以添加一個特定的語言標籤嗎?(javascript ??) –
是不是這個'JSON'?爲什麼你不使用適當的解析器?如果不是,這些ID是數字的,就像'「id」一樣簡單:(\ d +)'[可能會這樣做](https://regex101.com/r/iQ5jL0/1)。 – Jan