我正在尝试使用正则表达式来匹配前面有某些单词的文本(在这种情况下是“幻灯片”和“标题”)。我一直在尝试使用后视断言并将它们相互嵌套,但它似乎不起作用。另一个问题是我用来匹配的“幻灯片”和“标题”词之间还有一些其他文本。
我试过了:
(?<=slide(?<=title\\s=\\s)).*(?=\\\")
(?<=title\\s=\\s(?<=slide)).*(?=\\\")
关于如何做到这一点的任何建议?额外的斜线用于转义;我在objective-c中使用它,但我不知道这是否很重要。
我正在抓取 JSON 的一部分以获得更好的上下文(我希望在每张幻灯片中的“标题”之后获得标题):
slide = {
createdAt = "2013-06-18T20:06:50Z";
description = "<p>Due to the amount of attention paid to each organization's top prospects and early-round draft picks, many of the game's underrated prospects are perpetually obscured. Most of the time, these prospects are younger players who are housed in the low minors and still require considerable physical projection. At the same time, there are countless prospects on the older side of the age curve who have dipped off the radar due to injury.</p><p>Here's a look at one \"hidden gem\" from each organization who could make a push for the major leagues in the coming years.</p>";
embedCode = "";
externalId = "<null>";
id = 3219926;
photoHasCropExact = 1;
photoHasCropNorth = 0;
primaryPhoto = {
url = "http://img.bleacherreport.net/img/slides/photos/003/219/926/hi-res-5382332_crop_north.jpg";
};
title = "Each MLB Team's 'Hidden Gem' Prospect Fans May Not Know About";
updatedAt = "2013-06-18T22:26:30Z";
url = "<null>";