2015-12-01 40 views
-3
String test = "{helloworld=Text to be filtered}"; 

我需要从上面的字符串中获取“要过滤的文本”。 请帮忙。提前致谢。在android中筛选字符串

+0

发布您的尝试.. –

+0

对不起,我是初学者。我不知道。请帮忙。 –

+1

'“(?<==)[^ {}] *”' –

回答

0

在这种情况下,您可以使用String.split()方法。

String test = "{helloworld=Text to be filtered}"; 
String testAfterSplit[] = test.split("="); 

testAfterSplit[0]会拿着值 “{的HelloWorld” 和 testAfterSplit[1]将举行值 “文本过滤}

你可以阅读更多有关划分here

+0

我自己得到了答案! String test =“{helloworld =要过滤的文字}”; String test2 = test.replace(“{helloworld =”,“”); String test3 = test2.replace(“}”,“”); 现在我可以使用test3字符串:D这就是我发现自己。 –

0

您可以使用indexOf方法。它重塑你想要的角色位置。在这种情况下:

int pos = text.IndexOf("="); 
String filter = text.substring(pos, text.length()); 

它从位置=返回一个字符串到结尾。