我正在使用Flutter应用程序,我需要使用regExp从文本中提取列表图像,如下所示:
"property_gallery": [
"a:10:{i:1520;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9764.jpg\";i:1519;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9763.jpg\";i:1532;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9880.jpg\";i:1528;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9876.jpg\";i:1521;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9767.jpg\";i:1522;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9769.jpg\";i:1525;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9773.jpg\";i:1523;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9770.jpg\";i:1527;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9875.jpg\";i:1526;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9775.jpg\";}"
],
如何实现?
答案 0 :(得分:0)
这似乎是JSON对象。访问属性的正确方法是反序列化。查看Flutter文档中的JSON:https://flutter.io/json/
答案 1 :(得分:0)
void main() {
String str = "a:10:{i:1520;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9764.jpg\";i:1519;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9763.jpg\";i:1532;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9880.jpg\";i:1528;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9876.jpg\";i:1521;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9767.jpg\";i:1522;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9769.jpg\";i:1525;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9773.jpg\";i:1523;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9770.jpg\";i:1527;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9875.jpg\";i:1526;s:68:\"https://www.caribidreams.com/wp-content/uploads/2018/01/IMG_9775.jpg\";}";
RegExp exp = new RegExp(r"(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|gif|png)");
Iterable<Match> matches = exp.allMatches(str);
matches.toList().forEach((item) {
print(item[0]);
});
}