English 中文(简体)
Regex and RSS Feed
原标题:Regex and RSS Feed

i write a simple Rss Feed reader now i have this problem, in the item description i have the text but this text have this caracters <br/> for example

“my dog <br/>为黑体,他<br/>停留在表格上:“

现在,我已赢得从这辆车车上穿透的光线。

private static String IsMatch(String s, String pattern) {
    try {
        Pattern patt = Pattern.compile(pattern);
        Matcher matcher = patt.matcher(s);
        return matcher.group();
    } catch (RuntimeException e) {
      return "Error";
    } }

以及

String regex ="[<br/>]";

theString2=IsMatch(theString,regex);
 AppLog.logString(theString2);

...... 但这种方法总是不可逆转的。 谁能告诉我问题是什么?

best regads Antonio

最佳回答

The problem is that you never invoke find() on your matcher. You must invoke find() before invoking group() (and test that find() returns true).

我不知道您的“密码”方法是什么? 既然如此,它要么将相应(例如,<br/>>,假定你援引find( before)“Error”

Also, don t put the brackets around <br/> in your regexp, they are not needed.

I wouls really consider using replace instead of regexp for your purposes:

String s = "my dog <br/> is black and he <br/> stay on table ".replace("<br/>","");

作为一项建议,不作例外处理。 它们提供了不应隐藏的宝贵信息。 当问题发生时,它确实很难做到。

问题回答
String regex ="(<br/>)";

I think you need to pay attention to the grammar details about the regular expression: 1. escape the "<" like special characters

经常表达的不同语言有不同的规格





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签