【发布时间】:2011-02-17 04:26:38
【问题描述】:
我不喜欢其他人尽我的职责,但我不是 RegEx 专家,我认为你们会很有帮助。
我正在构建一个时事通讯 Android 应用程序,它使用一个暴露在 http 中的数组,如下所示:
Array
(
[Last_News] => Array
(
[last-news-1] => Array
(
[ID] => 711
[Title] => Here goes the title text
[Bullet] => Here goes the basic description of the news.
)
)
我正在尝试使用 RegEx:
String pattern = ".Ultima_Hora. => Array . .ultima_hora-[0-9]*.";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(str);
while (m.find()) { // Find each match in turn; String can't do this.
//String s = m.group();
String s = m.toString();
txt.setText(s);
}
但是,当我运行我的应用程序时,我可以看到从我的 httpclient 实现下载的所有文本。 有人可以举例说明我如何在 [last-news-1] 中打印数组? 非常感谢。
【问题讨论】:
-
为什么不使用 JSON?
-
一旦你的头撞到某个东西足够长的时间,寻求帮助并没有错。是的,正如所指出的,在应用程序之间传递数据是 JSON 的用途。 android 和 php 都可以原生对话 json。
-
我对那些暴露了“webservice”的人提出了同样的问题。如果他们将使用 JSOL 或 XML,我可以比您回答的更快地解析一些可用的库:)。该网站是this
-
另外,他们输出什么样的webservice print_r? =S
-
@Enrique: Abso-****-lutley,当然,如果可以的话。另外,你确定他们的 iPad 应用使用了这个精确的输出吗?
标签: java php android regex arrays