如何设置替换命令,如果目标将动态HREF正在添加是 [英] How to set replace command if target will dynamic href is comming
问题描述
这是我的HTML:
desc=desc=<a target="_blank" href="http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&id=27000000000000002519&search=">A. P. (DIR Series) Circular No. 46 dated June 14, 2005</a>
这里的id =值的变化和corporatelaws或directtaxlaws
here id= values changes and corporatelaws or directtaxlaws
String k = replace ( desc, "<a target=\"_blank\" href=\"http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=RULES&id=35000000000000001648&search=\">", "");
在说明我得到的HTML我有替代命令我,所以我从锚标记目标挑数据删除链接是动态的,其中id不同,我能够取代链接文本,其目标是
In desc I'm getting HTML I have replace command I have to remove link so I'm pick data from anchor tag target is dynamic where id varies I'm able to replace linking to text whose target is
<一个href=\"http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=RULES&id=35000000000000001648&search=\" rel=\"nofollow\">http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=RULES&id=35000000000000001648&search=\\
但是当过目标的变化,我的意思是说,如果ID改变,它不会取代链接文本。
but when ever target changes, I mean to say if id changes, it doesn't replace link as text.
请告诉我如何获取和设置ID值,这样,如果目标将是动态的,我们完全可以替代链接文本。我是新来的Android编程。
Please tell me how to get and set the id values so that if target will be dynamic we can replace link as text. I'm new to android programming.
String str = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&id=27000000000000002519&search=";
int indexoff = str.indexOf("id=");
int indexofl = str.indexOf("&search=");
String strsub = str.substring(indexoff + 3, indexofl - indexoff - 3);
String strstaticstring = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&id=" + strsub + "&search=";
String k = desc.replace(strstaticstring, "");
我想这一个,但我不知道如何挑选corporte或directtaxlaws会来。
i have trying this one bUt i dont know how to pick corporte or directtaxlaws will come ..
推荐答案
试试这个方法:
String str ="";
if(desc.contains("http://www.taxmann.com/corporatelaws/")==true)
{
str = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&id=27000000000000002519&search=";
}
if(desc.contains("http://www.taxmann.com/directtaxlaws/")==true)
{
str = "http://www.taxmann.com/directtaxlaws/fileopencontainer.aspx?Page=CIRNO&id=27000000000000002519&search=";
}
if(desc.contains("http://www.taxmann.com/corporte/")==true)
{
str = "http://www.taxmann.com/corporte/fileopencontainer.aspx?Page=CIRNO&id=27000000000000002519&search=";
}
或者你可以上/基地分割你的字符串,并检查它的话corporte,directtaxlaws等。
or you can split your string on the bases of "/" and check it for words corporte,directtaxlaws etc.
String str = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&id=27000000000000002519&search=";
string[] strarr = str.Split('/');
在strarr [3] U将得到corporatelaws值SA串用它来承包整个字符串desc中替换
in strarr[3] u will get corporatelaws value sa string use it for contracting whole string for replacing in desc
这篇关于如何设置替换命令,如果目标将动态HREF正在添加是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!