Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中从字符串中获取子字符串?_Android_Regex_String_Xpath_Substring - Fatal编程技术网

如何在android中从字符串中获取子字符串?

如何在android中从字符串中获取子字符串?,android,regex,string,xpath,substring,Android,Regex,String,Xpath,Substring,您好,我有一个长字符串,它有像“”和“”这样的html标记,我想从这个字符串中获取值,有人能给我一个解决方案如何从中获取值吗? 我的字符串是: <strong>1 king bed</strong><br /> <b>Entertainment</b> - Wired Internet access and cable channels <br /><b>Food & Drink</b> -

您好,我有一个长字符串,它有像“
”和“”这样的html标记,我想从这个字符串中获取值,有人能给我一个解决方案如何从中获取值吗? 我的字符串是:

<strong>1 king bed</strong><br /> <b>Entertainment</b> - Wired Internet access and cable channels <br /><b>Food & Drink</b> - Refrigerator, minibar, and coffee/tea maker<br /><b>Bathroom</b> - Shower/tub combination, bathrobes, and slippers<br /><b>Practical</b> - Sofa bed, dining area, and sitting area<br />
1张大床
娱乐-有线互联网接入和有线频道
餐饮-冰箱、迷你吧和咖啡/茶壶
浴室-淋浴/浴缸组合、浴袍和拖鞋
实用-沙发床、就餐区和休息区
我的尝试

int start = description_long.indexOf("Food");
                    int end = description_long.indexOf("<br />");
                    String subString = description_long.substring(start,
                            end);

                    System.out
                            .println("===============MY SUB STRING FROM STRING============="
                                    + start
                                    + ""
                                    + "============end======="
                                    + end + "");
int start=description_long.indexOf(“食品”);
int end=description_long.indexOf(“
”); String subString=description\u long.子字符串(开始, (完),; 系统输出 .println(“======================字符串中的我的子字符串====================” +开始 + "" +“================结束===========” +(完);;

我想获取食品和饮料浴室的值,任何人都可以告诉我如何在android中以编程方式以单独字符串获取这些值。

最好使用正则表达式或尝试解析


尝试此操作,但值必须以

    String key = "<b>Bathroom</b>";  //<b>Food & Drink</b>
    int start = htmlInput.lastIndexOf(key);
    String value = htmlInput.substring(start + key.length(), htmlInput.indexOf("<br />", start));
    System.out.println(value);
String key=“浴室”//饮食
int start=htmlInput.lastIndexOf(键);
String value=htmlInput.substring(start+key.length(),htmlInput.indexOf(“
”,start)); 系统输出打印项次(值);
您尝试过什么?也许你应该看看字符串上可能的操作。查看我的编辑查看我的尝试buddyhi先生谢谢,请帮助我,我已经尝试了,但没有得到正确的值…(请)。